IO::Lambda::DNS(3)
π IO::Lambda::DNS β DNS queries lambda style
Hi bestie! So this page is IO::Lambda::DNS(3) from the User Contributed Perl Documentation, and it's literally the glow-up your DNS lookups have been waiting for π¦
β¨ NAME β¨
IO::Lambda::DNS β DNS queries, but lambda style. Iconic. No cap.
πΈ DESCRIPTION πΈ
Okay so listen: this module gives you access to asynchronous DNS queries through Net::DNS. That's the whole vibe.
And because the author loves you, there are two functions that do the exact same operation β a constructor called new and a condition called dns. Pick whichever one matches your main character energy π
π SYNOPSIS π
Here's the code, copy-pasted exactly because I would never do you dirty like that:
use strict;
use IO::Lambda::DNS qw(:all);
use IO::Lambda qw(:all);
# simple async query
my $reply = IO::Lambda::DNS-> new( "www.site.com" )-> wait;
print (($reply =~ /^\d/) ? "Resolved to $reply\n" : "Error: $reply\n");
# parallel async queries
lambda {
for my $site ( map { "www.$_.com" } qw(google yahoo perl)) {
context $site, 'MX', timeout => 0.25;
dns { print shift-> string if ref($_[0]) }
}
}-> wait;
β OPTIONS β
The options that are specific to this module are:
timeoutordeadlineβ in seconds β±οΈretryβ in times π
Everything else β like nameservers, dnssec, etc etc (yes, the manpage literally says "etc etc", love that for us) β gets passed as is straight to the Net::DNS::Resolver constructor. So go read its man page for the details, bestie π«Ά
π USAGE π
π new β the constructor
Constructor new accepts Net::DNS-specific options (peep OPTIONS above, I got you) plus a query, and returns a lambda. That lambda takes no parameters, and gives you back either an IP address or a response object (depends on which call syntax you use, see below), or an error string.
new ($CLASS, %OPTIONS, $HOSTNAME) :: () -> ($IP_ADDRESS|$ERROR)
In the simple case, it takes a $HOSTNAME string and returns a string too β either an IP address or an error. To tell them apart, use the " /^\d/ " regexp. Why? Because it is guaranteed that no error message will begin with a digit, and no IP address will begin with anything other than a digit. Slay, honestly π₯
new (%OPTIONS, ($PACKET | $HOSTNAME, $TYPE)) :: () -> ($RESPONSE|$ERROR)
In the complex case, it takes either a Net::DNS::Packet object, or a $HOSTNAME and $TYPE string β where that $TYPE can be one of A, MX, etc DNS query type. For the exact syntax, see "bgsend" in Net::DNS::Resolver.
It returns either a Net::DNS::RR object or an error string β¨
π¦ dns β condition wrapper over new
That's it. That's the whole thing. It's a condition wrapper over new:
dns (%OPTIONS, $HOSTNAME) -> $IP_ADDRESS|$ERROR
dns (%OPTIONS, ($PACKET | $HOSTNAME $TYPE)) -> $RESPONSE|$ERROR
π SEE ALSO π
Go check out:
IO::LambdaNet::DNS::Resolver
Both linked, both worth your time. Periodt π
πΈ AUTHOR πΈ
Dmitry Karasik, <dmitry@karasik.eu.org>. Give him his flowers, he earned them π
That's the whole page bestie, you're officially a DNS lambda girlie now π§
Ok bye ily, this was perl v5.42.2 and the page itself is dated 2026-02-15 β the header up top says IO::Lambda::DNS(3), but you already knew that π
π¦ where this page comes from
- alpine 3.24: perl-io-lambda-doc 1.34-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms