http://www.perlmonks.org?node_id=117994


in reply to Re (tilly) 1: Strict, strings and subroutines
in thread Strict, strings and subroutines

I thought about that one too, but it also follows @ISA. You can fix that with this:
do { local @ISA; __PACKAGE__->can("do_$type") }->();
Much smoke. Many mirrors. In fact, I'd cache the result too:
BEGIN { my %cache; sub do_it { my $func = shift; ($cache{$func} ||= do { local @ISA; __PACKAGE__->can("do_$fun") }) ->(@_); } } ... do_it("function", $arg1, $arg2, @more_args);

-- Randal L. Schwartz, Perl hacker