Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: strange code (de)referencing behavior

by choroba (Cardinal)
on Feb 10, 2012 at 15:37 UTC ( [id://953051]=note: print w/replies, xml ) Need Help??


in reply to strange code (de)referencing behavior

Calling a subroutine this way
&{...}
forwards the @_ arguments. (Try sub f { say while $_ = shift; warn "Called\n" } %d = (1 => \&f); sub g { &{$d{1}} }; g(1, 2).) If you want to avoid that, use -> for dereference:
$dispatchTable{$fname}->();

Replies are listed 'Best First'.
Re^2: strange code (de)referencing behavior
by ikegami (Patriarch) on Feb 10, 2012 at 19:26 UTC

    Although I do prefer the arrow notation, the minimal change solution is actually

    &{$dispatchTable{$fname}}()

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-20 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found