in reply to use slack;
I usually do this:
The reason this works is because the construct \&{$func} is exempt from the rule of strict references. It is as far as I know not documented in earlier perls, but code support for this construct has been in for a long time. It is documented in bleadperl IIRCuse strict; sub foo { print "bar\n" } my $func = "foo"; my $func_ref = \&{$func}; $func_ref->();
The construct is often used in AUTLOAD like this:
Autark.sub AUTOLOAD { # get params and function # ... my $func_ref = \&{$func}; goto &{$func_ref}; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: use slack;
by Dominus (Parson) on Dec 21, 2000 at 20:44 UTC | |
by tilly (Archbishop) on Dec 22, 2000 at 00:10 UTC | |
Re: Re: use slack;
by epoptai (Curate) on Dec 21, 2000 at 07:23 UTC | |
by autark (Friar) on Dec 21, 2000 at 07:45 UTC |