in reply to Variable behaving as a function call
If you are on Perl 5.16 or above, you can take references to most built-in functions, using the syntax: \&CORE::builtin.
If you are on an earlier version, that isn't allowed, so you'd need to use wrappers:
$b = 0; $x = $b ? sub{ gmtime( @_ ) } : sub{ localtime( @_ ); }; print $x->( 123456 );; 1 0 0 1 0 70 4 0 0 $b = 1; $x = $b ? sub{ gmtime( @_ ) } : sub{ localtime( @_ ); }; print $x->( 123456 );; 1 0 0 1 0 70 4 0 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Variable behaving as a function call
by ikegami (Patriarch) on May 11, 2016 at 19:48 UTC |