Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So the variable I want to create will look like my $q1, my $q2 and so on and so on. And the params are identical, they are also param("q1"), param("q2), etc. I don't want to hard code every bloody variable in there and was wondering if this could be done by a loop to create and assign all of these variables?
I was thinking something like
But under strict, the variables would only be accessibly until the loop is over. Can anyone come up with a way to do this?my $cnt = 0; for ( 1 .. 40) { $cnt++; my $q$cnt = param("q$cnt"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating variables in a loop
by merlyn (Sage) on May 18, 2005 at 22:30 UTC | |
|
Re: creating variables in a loop
by davido (Cardinal) on May 19, 2005 at 00:21 UTC | |
|
Re: creating variables in a loop
by mrborisguy (Hermit) on May 18, 2005 at 22:29 UTC | |
by Fletch (Bishop) on May 19, 2005 at 00:14 UTC | |
by merlyn (Sage) on May 18, 2005 at 22:33 UTC | |
by mrborisguy (Hermit) on May 18, 2005 at 22:54 UTC | |
by merlyn (Sage) on May 18, 2005 at 23:54 UTC |