in reply to How to call subroutines using variables ?
Or you could try:eval "&$s()";
To rewrite the second example to make it nicer:&{ &UNIVERSAL::can('main', $s) }();
(update: should probably check the return from 'can' to ensure it returns a function reference)my $funcRef = &UNIVERSAL::can('main', $s); if( ref($funcRef) eq 'CODE' ) { &$funcRef(); } else { warn "Function $s not found in package main!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to call subroutines using variables ?
by Joost (Canon) on Mar 22, 2007 at 23:10 UTC | |
by Anonymous Monk on Aug 13, 2007 at 20:49 UTC | |
by Joost (Canon) on Aug 13, 2007 at 20:52 UTC | |
|
Re^2: How to call subroutines using variables ?
by chromatic (Archbishop) on Mar 23, 2007 at 05:20 UTC |