> -Original Message-
> From: Brian Ling [mailto:brian.ling@;bbc.co.uk]
> Sent: Monday, November 04, 2002 4:17 PM
> To: [EMAIL PROTECTED]
> Subject: Variable names
>
>
> Hi all
>
> Is it possible to use the string value of a variable to
> create a new hash i.e.
>
> My $name = "fred";
>
From: "Brian Ling" <[EMAIL PROTECTED]>
> Is it possible to use the string value of a variable to create a new
> hash i.e.
>
> My $name = "fred";
>
> Can I use $name to create a hash called fred?
This is really a FAQ :-(
Yes you can, but you don't want to.
Please read
Why it's stupid to
From: "Dario Greco" <[EMAIL PROTECTED]>
> i must create an array and an hash and store them for each cycle of a
> "while". i want name these variables @array1, @array2... and %hash1,
> %hash2... in which 1,2 etc are the number of cycle of the "while".
No you don't.
Please read "Why it's stupid to
You can use symbolic references:
perldoc perlref
(see Symbolic references section)
$i=0;
While(bla bla){
$i++;
$a_var_name="array$i";
$h_var_name="hash$i";
#
@$a_var_name=(); #this for instance clears @array1 if your are in the first
loop.
%$h_var_