in reply to Re^2: Dynamic interpolation in a string with a scalar variable?
in thread Dynamic interpolation in a string with a scalar variable?
some way to do it that was native to Perl.
The "native" way: with a closure:
my $variable = 3; my $string = sub { return "Variable: $variable\n"; }; print &$string; $variable = 4; print &$string;
I assume here that by "native" you mean "without using a module". However, be advised that many modules are written using "native" pure perl and that modules are as much a part of the language as the print function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Dynamic interpolation in a string with a scalar variable?
by nysus (Parson) on Dec 01, 2015 at 00:48 UTC |