in reply to Sub ref from string without eval
I suspect this is an XY Problem, but you can do this using Symbolic references. This will not work with strict refs in place (you do use strict, right?), so your code might look like
so your code might look like
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.
In Section
Seekers of Perl Wisdom