in reply to Evaluating variables when called
None of these answers does it exactly the way you want. Take a look:
Cheers - L~R# Option 1 my $date = 'scalar localtime()'; print eval $date; # Option 2 package Current_Date_Stamp; sub TIESCALAR { bless {}, $_[0] } sub STORE { return 1 } sub FETCH { return scalar localtime() } package main; tie my $date, "Current_Date_Stamp"; print "The current date is $date\n"; # Option 3 use Interpolation date => sub {localtime()}; print "Today's date is $date{now}";
|
|---|