Skip to content

Instantly share code, notes, and snippets.

@richardjharris
Created December 12, 2012 13:43
Show Gist options
  • Select an option

  • Save richardjharris/4267810 to your computer and use it in GitHub Desktop.

Select an option

Save richardjharris/4267810 to your computer and use it in GitHub Desktop.
perl dns lookups
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