mr_p has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
I wanted to add $depth into the @urls with separated by pipe '|' symbol, Is it possible to pass multiple arguments to the callback routine?
So, I would like to pass $depth as argument to depth, if its possible.
Thanks.
Here is an Example code.
Mojo::IOLoop->recurring( 0 => sub { for ($active + 1 .. $max_conn) { # Dequeue or halt if there are no active crawlers anymore return ($active or Mojo::IOLoop->stop or $totalPagesVisite +d > $maxPages) unless my $url = shift @urls; # Fetch non-blocking just by adding # a callback and marking as active ++$active; say "getting link: $url"; ($depth, $myLink) = split ('\|', $url); $ua->get($myLink => \&get_callback); } } ); sub get_callback { my (undef, $tx) = @_; ...... push(@urls, "$depth+1|$newLink"); ...... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing multiple arguments to CallBack routine.
by mr_p (Scribe) on May 23, 2013 at 17:37 UTC | |
by johngg (Canon) on May 23, 2013 at 19:06 UTC | |
by mr_p (Scribe) on May 23, 2013 at 19:56 UTC |