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
    I got my own answer.

      Perhaps you could share it with us so that other monks who might have the same query and see your post can find a solution :-)

      Cheers,

      JohnGG

        This is what I am using now.
        if ($myDepth < ($maxDepth +1 ) ) { my $tx=$ua->get($url); get_callback(\$tx, $myDepth+1); }