| duffman 2005-05-09, 4:12 pm |
| hi-
i have a bunch of variables that i get data into via cgi. because i'm using strict, they all have "my" infront of them.
what i'm trying to do is create a string that i can pass to another cgi of all the variables. eg ?&month=$month&day=$day&year=$year.
now, i was thinking i could very easily just create an array with the names of the scalars, and loop though and put the values in the string. something like this:
PHP:
my $month = 5;
my $day = 7;
my $year = 2005;
my $params = "?";
my @list = qw( month day year );
foreach my $name (@list){
$params .= "&".$name."=".${$name};
}
print $params;
first of all, because of the "my"'s, the values aren't visible using this dynamic method or some reason. saying print $month inside the foreach works, but ${$name} does not, for some reason...
secondly, when i run it using "use strict", i get an error:
"Can't use string ("month") as a SCALAR ref while "strict refs" in use"
are there ways to get around this? |