http://qs321.pair.com?node_id=963028


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
my $x = 'Foo'; my $sub_ref = do { no strict 'refs'; \&{$x}; };
so your code might look like
my $x = 'Foo'; my $sub_ref = \&{$x};
Update: It appears my $sub_ref = \&{'Foo'}; passes strict when &{'Foo'}; does not. Huh?

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.