in reply to Re^3: Stateful Browsing and link extraction with AnyEvent::HTTP
in thread Async DNS with LWP
My second attempt was slightly better in that it can send off ten different DNS packets but receives a reply from the last request ten times (not what I wanted):#!/usr/bin/perl -w use strict; use warnings; use AnyEvent::DNS; my ($domain); my (@domains,@condvars); my $resolver = AnyEvent::DNS::resolver; while ($domain = <>;) { # clean off newline chomp $domain; # send dns packets $resolver->resolve($domain,"*",my $condvar = AnyEvent->condvar); # receive dns packets $condvar->recv; print "$domain\n"; }
The problem is that $condvar seems to be working like a reference to an object and so each of the 10 $condvars in the stack end up being whatever the last $condvar was. I've tried typeglobbing but this just causes compilation errors. Does anybody know how to do this right?#!/usr/bin/perl -w use strict; use warnings; use AnyEvent::DNS; my ($domain); my (@domains,@condvars); my $resolver = AnyEvent::DNS::resolver; while (1) { # send dns packets for my $i (1..10) { $domain = <>; # clean off newline chomp $domain; $resolver->resolve($domain,"*",my $condvar = AnyEvent->condvar); push @condvars, $condvar; } # receive dns packets while (my $condvar = pop @condvars) { $condvar->recv; print "$domain\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: AnyEvent::DNS is effectively synchronous?
by Corion (Patriarch) on Oct 05, 2010 at 11:57 UTC | |
by jc (Acolyte) on Oct 05, 2010 at 12:51 UTC | |
by jc (Acolyte) on Oct 05, 2010 at 14:05 UTC | |
by Corion (Patriarch) on Oct 05, 2010 at 14:11 UTC | |
by jc (Acolyte) on Oct 05, 2010 at 15:01 UTC | |
by Corion (Patriarch) on Oct 05, 2010 at 15:47 UTC |