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:
Much smoke. Many mirrors. In fact, I'd cache the result too:do { local @ISA; __PACKAGE__->can("do_$type") }->();
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re:{3} Strict, strings and subroutines
by jeroenes (Priest) on Oct 10, 2001 at 18:44 UTC | |
by merlyn (Sage) on Oct 10, 2001 at 19:45 UTC | |
Re (tilly) 3: Strict, strings and subroutines
by tilly (Archbishop) on Oct 10, 2001 at 18:57 UTC | |
by gbarr (Monk) on Oct 10, 2001 at 19:12 UTC | |
by tilly (Archbishop) on Oct 10, 2001 at 19:24 UTC | |
by gbarr (Monk) on Oct 10, 2001 at 20:19 UTC | |
Re: Re: Re (tilly) 1: Strict, strings and subroutines
by gbarr (Monk) on Oct 10, 2001 at 19:16 UTC | |
by $code or die (Deacon) on Oct 10, 2001 at 22:03 UTC | |
by tilly (Archbishop) on Oct 10, 2001 at 22:22 UTC |
In Section
Seekers of Perl Wisdom