tinita has asked for the wisdom of the Perl Monks concerning the following question:
my $subname = "package::sub"; if (my $coderef = main->can($subname)) { $coderef->(@args); }
i thought the following would generate an error:
but it works fine.use strict; my $coderef = \&$subname; $coderef->(@args);
syntactically &{$sub} is equal to ${$var}, right?
so is \&{$sub} to \${$var}.
but while the latter one does not work with strict, the former does.
is this documented somewhere or am I missing the obvious?
update:
*blush*
forget it...
perldoc strict: There is one exception to this rule: $bar = \&{'foo'}; &$bar;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strict and symbolic subroutine refs
by Zaxo (Archbishop) on Jul 24, 2004 at 14:29 UTC | |
|
Re: strict and symbolic subroutine refs
by nothingmuch (Priest) on Jul 24, 2004 at 14:29 UTC | |
by tinita (Parson) on Jul 24, 2004 at 14:42 UTC | |
by nothingmuch (Priest) on Jul 25, 2004 at 07:02 UTC | |
by tinita (Parson) on Jul 25, 2004 at 09:49 UTC |