in reply to Re^3: How to call sub defined in a variable?
in thread How to call sub defined in a variable?
&{$sub_i_want_to_call};You probably want that to be &{$sub_i_want_to_call}(); (or the equivalent $sub_i_want_to_call->()). Subroutine calls with & but without parens give the callee direct access to the caller's @_, including the ability to modify it:
$ perl -w sub foo { my $foo = shift } sub bar { &foo; warn @_ } bar("baz","quux","\n"); __END__ quux
|
---|