in reply to calling functions from data in variables
Or if you're feeling particularly devilish you can just abuse the lack of checking for strictures when creating subroutine references e.gsub foo { print "in foo\n" } my %dispatch = ( foo => \&foo, bar => sub { print "in bar\n" }, ); my @data = qw/ foo bar /; $dispatch{$_}->() for @data; __output__ in foo in bar
Ok, so you probably wouldn't want to do it like that, but it's always an option ;)sub foo { print "in foo\n" } (\&{"foo"})->(); __output__ in foo
_________
broquaint
|
|---|