in reply to Variable behaving as a function call
Hi dirtdog,
I believe you are looking for a CODEREF. You could do:
to create a reference to an anonymous subroutine.my $time_zone_func = ( $file =~ /^London/ ) ? sub { gmtime shift } : sub { localtime shift };
You dereference the coderef with &{ $ref } so you would call it as:
or$foo = &$time_zone_func( time );
$bar = $time_zone_func->( time );
Hope this helps!
|
|---|