Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How To Call An Anonymous Subroutine?

by runrig (Abbot)
on Apr 25, 2012 at 18:07 UTC ( #967133=note: print w/ replies, xml ) Need Help??


in reply to How To Call An Anonymous Subroutine?

You invoke an anonymous sub with ->(). Your sub would be invoked with $new_resolvers{"dns-extern"}[0]->($ip_address). The way you have your loop written, you'll have to tell the difference between a scalar and a sub though. You could rewrite the loop as:

print "getting new resolvers for dns server $dns_server\n"; for my $resolver ( @{$new_resolvers{$dns_server}} ) { if (ref $resolver) { print "$_\n" for $resolver->($ip); } else { print "$resolver\n\n"; } } print "\n";
I don't know where $ip is supposed to come from, but that's the way you have your anonymous sub written.


Comment on Re: How To Call An Anonymous Subroutine?
Select or Download Code
Re^2: How To Call An Anonymous Subroutine?
by Plankton (Priest) on Apr 25, 2012 at 19:31 UTC
    Thank you runrig. that's what I needed!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-09-18 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (116 votes), past polls