in reply to Re^11: Function name in a variable, can't recall the concept (introspection with ->can )
in thread Function name in a variable, can't recall the concept
\&$name works even under strict refs. No need to turn it off.
Perfect, makes the code even simpler
You need to return something (undef?) in the else case.
Good question actually. My tests didn't seem to need it...
sub test { ... } ; ... if ( my $s = get_sub_by_name( "", "test" ) ) { $s->() ; } else { print "No\n" ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: Function name in a variable, can't recall the concept (introspection with ->can )
by ikegami (Patriarch) on Apr 19, 2019 at 18:55 UTC |