in reply to interpolate variable in a hash?
You can make references to the variables instead. You'll have to do a little dereferencing in your print statement.
%hash = ( key1 => \$foo, key2 => \$bar, key3 => \$baz, ); print "Bar: ${ $hash{key2} }\n"; $bar++; print "Bar: ${ $hash{key3} }\n";
I've tested similar code on my machine.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|