in reply to Technique for building arguments from function name?
I don't recommend this technique, but have a look at AUTOLOAD:
our $AUTOLOAD; sub AUTOLOAD { if( $AUTOLOAD =~ /.*?::function_(\w+)$/ ) { function_x( $1 ); } else { die "Unknown function '$AUTOLOAD' called"; }; }
Update: Perlbotics points out that my approach needs to skip main:: or other package names.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Technique for building arguments from function name?
by nysus (Parson) on Dec 04, 2017 at 19:56 UTC | |
by shmem (Chancellor) on Dec 04, 2017 at 21:38 UTC | |
by LanX (Saint) on Dec 04, 2017 at 20:55 UTC | |
by haukex (Archbishop) on Dec 05, 2017 at 06:16 UTC | |
by LanX (Saint) on Dec 06, 2017 at 16:04 UTC |