I have recently installed Redhat Linux, and when I copied my web page from my PC to linux, it did not execute the scripts properly. I have also updated my perl version with the latest update on you web site (14/05/99)and still had the same problem. After some debugging I have found what the problem is: I pass a reference to an associate array to a subroutine. This subroutine then fills in this array. But the items this subroutine enters into the array are not visable outside this array as they should be as I passed the array by reference. These scripts have been working on my PC and on ISP unix machine. The contenets of the script are below. #!/usr/bin/perl &parse_input(*login_form); #the login_form is empty it does not get filled as it should $userid = $login_form{'userid'}; $pass = $login_form{'pass'}; #the subroutine sub parse_input { if (defined(@_)) { local(*input)=@_; } else { local(*input)="*cgiinput"; } local ($temp,@pairs); if (&form_method eq 'POST') { read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); } else { $temp=$ENV{'QUERY_STRING'}; } if ($temp ne '') { @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split (/=/,$item,2); $content=~tr/+/ /; $content=~ s/%(..)/pack("c",hex ($1))/ge; if (!defined($input{$key})) { $input{$key}=$content; } else { $input{$key} .= "\0 $content"; } } return 1; } else { return 0; } }
You can change the perl fucntion to return the actual array instead of playing the by-refreence game, whcih is totally evil. At a first fast glance I got scaried by things like $input{$key} .= "\0$content"; I'd suggest you rather use the CGI module if you want to parse this kind of free form variables.