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

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Variable behaving as a function call
by ikegami (Patriarch) on May 11, 2016 at 19:48 UTC
    You need to replace @_ with $_[0] because the argument is evaluated in scalar context.