Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So, I'm trying to make push really see it as:#(no this isn't my actuall code but a simplified example) @vars =("num", "alpha" ); $num=1; $alpha="a"; for ($i=0; $i<@vars;$i++){ # create an array @num with value from $num, etc # create an array @alpha with value from $alpha, etc push ( @($vars[$i]), $($vars[$i]); }
except I've got to do this with about 20 arrays, therefore the need for "variable substition" to keep the code clean. How do I do this ?push (@num, $num) and push (@alpha, $alpha)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: push with variable substitution ?
by gnat (Beadle) on Jun 19, 2000 at 22:33 UTC | |
|
Re: push with variable substitution ?
by merlyn (Sage) on Jun 19, 2000 at 22:10 UTC | |
|
Re: push with variable substitution ?
by eduardo (Curate) on Jun 19, 2000 at 22:18 UTC | |
|
Re: push with variable substitution ?
by lhoward (Vicar) on Jun 19, 2000 at 22:13 UTC |