Created
December 12, 2012 13:43
-
-
Save richardjharris/4267810 to your computer and use it in GitHub Desktop.
perl dns lookups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use AnyEvent; | |
| use AnyEvent::DNS; | |
| my %results; | |
| my $cv = AnyEvent->condvar; | |
| open my $fh, '<', 'input.txt' or die "read: $!"; | |
| while (my $host = <$fh>) { | |
| chomp $host; | |
| $cv->begin; | |
| AnyEvent::DNS::a $host, sub { $results{$host} = shift; $cv->end; }; | |
| } | |
| $cv->recv; | |
| print "$_\t$results{$_}\n" for keys %results; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment