in reply to 2 $vars 2 1 $var
This is called a symbolic reference and is disallowed under use strict, hence the temporary disabling of strict refs.$childHood = "a young kid"; $test = "child"; { no strict "refs"; ${$test."Hood"} = "an old man"; }
It will only work if $childHood is not a lexical (my) variable. If it is a lexical, your only recourse is eval.
Note that needing to do this usually indicates you are not storing your data in the best possible way. Perhaps you could do something like:
(last bit added simultaneously with Roy Johnson's comment below)my %Hood; $Hood{child} = "a young kid"; $test = "child"; $Hood{$test} = "an old man";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: 2 $vars 2 1 $var
by Roy Johnson (Monsignor) on Feb 10, 2005 at 22:50 UTC |