in reply to Re: Variable behaving as a function call
in thread Variable behaving as a function call
Neither will work for operators such as gmtime and localtime, though.
Since 5.16:
my $time_zone_func = $file =~ /^London/ ? \&CORE::gmtime : \&CORE::localtime; strftime($date_format, $time_zone_func->(time))
Backwards compatible:
ormy $time_zone_func = $file =~ /^London/ ? sub { gmtime($_[0]) } : sub { localtime($_[0]) }; strftime($date_format, $time_zone_func->(time))
my $time_zone_func = sub { $file =~ /^London/ ? gmtime($_[0]) : localtime($_[0]) }; strftime($date_format, $time_zone_func->(time))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Variable behaving as a function call
by AnomalousMonk (Archbishop) on May 11, 2016 at 19:35 UTC |