rbaldwin has asked for the wisdom of the Perl Monks concerning the following question:
i want to loop through creating $var1 = 'x'; $var2 = 'y' and $var3 = 'z'; as in@array = ('var1=x','var2=y','var3=z');
But obviously that doesn't work or i wouldn't be asking. So what exactly is the correct syntax? Your help is much appreciated.foreach (@array) { my ($var,$val) = split(/=/,$_); $$var = $val; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: A variable variable.
by Ovid (Cardinal) on Nov 23, 2000 at 04:16 UTC | |
by Dominus (Parson) on Nov 23, 2000 at 04:53 UTC | |
by tilly (Archbishop) on Nov 23, 2000 at 07:16 UTC | |
|
Re: A variable variable.
by quidity (Pilgrim) on Nov 23, 2000 at 04:23 UTC | |
by tilly (Archbishop) on Nov 23, 2000 at 07:01 UTC | |
|
Re: A variable variable.
by rbaldwin (Novice) on Nov 23, 2000 at 18:41 UTC | |
|
Re: A variable variable.
by spaz (Pilgrim) on Nov 23, 2000 at 06:07 UTC |