in reply to 2 $vars 2 1 $var

$childHood = "a young kid"; $test = "child"; { no strict "refs"; ${$test."Hood"} = "an old man"; }
This is called a symbolic reference and is disallowed under use strict, hence the temporary disabling of strict refs.

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:

my %Hood; $Hood{child} = "a young kid"; $test = "child"; $Hood{$test} = "an old man";
(last bit added simultaneously with Roy Johnson's comment below)

Replies are listed 'Best First'.
Re^2: 2 $vars 2 1 $var
by Roy Johnson (Monsignor) on Feb 10, 2005 at 22:50 UTC
    Note that in most situations where you want to do something like this, it's often better to use a hash:
    my %hood = (child => 'a young kid'); $test = 'child'; $hood{$test} = 'an old man';

    Caution: Contents may have been coded under pressure.