TecoDaN has asked for the wisdom of the Perl Monks concerning the following question:
$aword = "foo";
$containmentvar = '$aword';
print $containmentvar;
---
What I want the code to do is print the word foo from the scalar variable $containmentvar that is a character string containing the variable name $aword. The above code won't do that. How could I make it possible with a code similar to the above?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE (tilly) 1: substitution of variable within a variable
by tilly (Archbishop) on Sep 24, 2000 at 05:23 UTC | |
by ar0n (Priest) on Sep 24, 2000 at 05:33 UTC | |
|
(jeffa) Re: substitution of variable within a variable
by jeffa (Bishop) on Sep 24, 2000 at 05:10 UTC | |
|
update: substitution of variable within a variable
by TecoDaN (Initiate) on Sep 24, 2000 at 05:22 UTC | |
|
Re: substitution of variable within a variable
by TecoDaN (Initiate) on Sep 24, 2000 at 07:04 UTC | |
by mistaker (Acolyte) on Sep 25, 2000 at 02:21 UTC |