in reply to Evaluating variables when called

I actually wrote a module that handles this once; feel free to use its code:
# DynInterp.pm package DynInterp; use overload '""' => 'stringify'; sub new { my $class = shift; bless [@_], $class; } sub stringify { my $this = shift; return join('', map { ref($_)eq'SCALAR'?$$_:ref($_)eq'ARRAY'?"@{$_ +}":$_ } @$this); } 1;
And here is an example file with which to use it:
# --------------------- # dyninterp.pl #!/usr/bin/perl -l use DynInterp; $x = new DynInterp('the value of $y is ', \$y, '.'); $z = new DynInterp('the value of $y is ', \@y, '.'); $y=5; print $x; $y=8; print $x; @y = qw(a b c d); print $z; $"=','; print $z; $"='.'; print $z;
In your particular case you would do
$var = new DynInterp('date ', \$date); $date = localtime; print $var;
--Stevie-O
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc