Forgive me if I'm missing something, but I've used the following:
$varnew = "$varold" ;
$varnew will return the same value as $varold did/does.
Just like if you wanted to initialize a bunch of counters: $ctr1 = $ctr2 =
$ctr3 = $ctr4 = 1; .
I don't know that it is proper form, but it seems to work.
-----Original Message-----
From: Paul [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 12, 2001 12:23 PM
To: Chirag Patel; '[EMAIL PROTECTED]'
Subject: Re: making a variable name a variable value?
--- Chirag Patel <[EMAIL PROTECTED]> wrote:
> I was wondering how to make a variable name the value of another
> variable.
> for example: $name = "jerry";
> how can I establish a variable with the name
> $jerry ?
Several ways. c.f. the other responses, but you could also use an eval:
eval "\$$name = 'foo'"; # sets $jerry to 'foo'
This isn't pretty, but works.
However, I *strongly* suggest you 'use strict;', which will probably
give you six kinds of hell for trying to use symbolic references.
Symrefs are easy to do, but often a bad idea.
If you can read and understand the vars pragma module and use that
syntax intelligently, then you're well on your way to understanding
*why* it could be a bad idea, as well as having alternatives....
Why did you need this?
Is there a simpler way?
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/