And here is an example file with which to use it:# 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;
In your particular case you would do# --------------------- # 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;
$var = new DynInterp('date ', \$date); $date = localtime; print $var;
$"=$,,$_=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
In reply to Re: Evaluating variables when called
by Stevie-O
in thread Evaluating variables when called
by qadwjoh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |