On 12 Jun 2001 09:15:37 -0700, Chirag Patel wrote:
> Hi there,
>
> I was wondering how to make a variable name the value of another variable.
> Do we do this using pointers?
>
> for example:
> $name = "jerry";
>
> how can I establish a variable with the name
> $jerry ?
>
> thanks for the help,
>
> c.
>
>
This is called symbolic referencing. Just use it like a normal
reference:
<snip href="perldoc perlref">
$name = "foo";
$$name = 1; # Sets $foo
${$name} = 2; # Sets $foo
${$name x 2} = 3; # Sets $foofoo
$name->[0] = 4; # Sets $foo[0]
@$name = (); # Clears @foo
&$name(); # Calls &foo() (as in Perl 4)
$pack = "THAT";
${"${pack}::$name"} = 5; # Sets $THAT::foo without eval
</snip>
--
Today is Pungenday, the 17th day of Confusion in the YOLD 3167