in reply to package sub and code reference
and now $codeRefs{SubRoutine1}->(@args) will invoke Package::SubRoutine1(@args), or an inherited version if needed, or die if nothing else.my %codeRefs = map { "Package"->can($_) || sub { die "can't find $_" } } qw(SubRoutine1 SubRoutine2 SubRoutine3);
Yeah, scary deep magic. And it even works under "use strict". Augh!
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: package sub and code reference
by tilly (Archbishop) on Sep 28, 2001 at 04:48 UTC |