in reply to Sub ref from string without eval
my $x = 'Foo'; my $sub_ref = do { no strict 'refs'; \&{$x}; };
Update: It appears my $sub_ref = \&{'Foo'}; passes strict when &{'Foo'}; does not. Huh?my $x = 'Foo'; my $sub_ref = \&{$x};
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sub ref from string without eval
by moritz (Cardinal) on Apr 02, 2012 at 15:01 UTC | |
by ikegami (Patriarch) on Apr 02, 2012 at 19:09 UTC | |
|
Re^2: Sub ref from string without eval
by kejohm (Hermit) on Apr 02, 2012 at 22:46 UTC |