Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Passing multiple arguments to CallBack routine.

by mr_p (Scribe)
on May 23, 2013 at 17:15 UTC ( #1034992=perlquestion: print w/replies, xml ) Need Help??
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.


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 :-)



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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1034992]
Approved by johngg
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2018-02-24 06:36 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.