dirtdog has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I'm attempting to assign a function to a variable and then call the function from the variable. For example:
if ( $file =~ /^London/ ) { $time_zone_func = gmtime; } else { $time_zone_func = localtime; } my $prev_days = $4 * 86400; if ( $prev_days ) { $TIMESTAMP = strftime($date_format, $time_zone_func(time - $prev_day +s)); } else { $TIMESTAMP = strftime($date_format, $time_zone_func(time)); }
This does not work and I'm guessing that it's not possible, but thought I'd ask the Guru's to be sure. Obviously, there is a workaround, but this seemed like the least amount of code to accomplish the task if it worked.
Thanks a lot
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Variable behaving as a function call
by AnomalousMonk (Archbishop) on May 11, 2016 at 19:19 UTC | |
by ikegami (Patriarch) on May 11, 2016 at 19:31 UTC | |
by AnomalousMonk (Archbishop) on May 11, 2016 at 19:35 UTC | |
by dirtdog (Monk) on May 11, 2016 at 19:23 UTC | |
|
Re: Variable behaving as a function call
by LanX (Saint) on May 11, 2016 at 19:39 UTC | |
|
Re: Variable behaving as a function call
by BrowserUk (Patriarch) on May 11, 2016 at 19:44 UTC | |
by ikegami (Patriarch) on May 11, 2016 at 19:48 UTC | |
|
Re: Variable behaving as a function call
by 1nickt (Canon) on May 11, 2016 at 19:44 UTC |