Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Managing capture

by LanX (Canon)
on Feb 19, 2013 at 12:10 UTC ( #1019536=note: print w/ replies, xml ) Need Help??


in reply to Managing capture

to answer the question "how do I pass a method as a callback"

doSomething is evidently a method, so it gets my ($self,%args) =@_ in the first line.

Now if you wanna call an anonymous method $args{on_succes}, do something like

$self->$args{on_succes}(ARG_LIST);

Assure that the callback itself takes self again from the args!

 on_success => sub { my ($self,%args); }

Cheers Rolf

UPDATE:

sigh ... there is a parsing problem with $self->$args{on_succes}(ARG_LIST);

You'll need to use a temporary var $code_ref

my $code_ref=$args{on_succes}; $self->$code_ref(ARG_LIST);


Comment on Re: Managing capture
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2015-07-06 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (73 votes), past polls