Perl Error - $* is no longer supported in Perl 5.10

software development

#1

I have a generic PERL script that contains basic sub routines. Everything has been working for over five years until the upgrade to Perl 5.10. It seems that the pattern matching $* is not supported in this newer version. I understand that there are two functions (/s and /m) which would be used instead. I do not know the correct syntax to replace the code in my script. Please, is there anyone out there who can fix this problem with my code. I use this script on over 50 web sites.

There are only two simple routines. the code is shown below:

sub PrintVariables {
local (%in) = @;
local ($old, $out, $output);
$old = $; $ =1;
$output .= “

”;
foreach $key (sort keys(%in)) {
foreach (split("\0", $in{$key})) {
($out = $
) =~ s/\n/
/g;
$output .= “

$key
$out
”;
}
}
$output .= “”;
$* = $old;

return $output;
}

PrintVariablesShort

Nicely formats variables in an associative array passed as a parameter

Using one line per pair (unless value is multiline)

And returns the HTML string.

sub PrintVariablesShort {
local (%in) = @;
local ($old, $out, $output);
$old = $; $ =1;
foreach $key (sort keys(%in)) {
foreach (split("\0", $in{$key})) {
($out = $
) =~ s/\n/
/g;
$output .= “$key is $out
”;
}
}
$* = $old;
return $output;
}


#2

Based on the search/replaces you’re performing here (\n to
), I strongly suspect that setting $* is unnecessary. Try removing all four lines which mention it and see if your script still works.


#3

I removed the four lines and the form still does not work:

Error log report:

[Wed Aug 25 10:21:47 2010] [error] [client 174.55.33.42] Can’t open !, referer: http://www.benningtonandson.com/contact.html
[Wed Aug 25 10:21:47 2010] [error] [client 174.55.33.42] Premature end of script headers: request.pl, referer: http://www.benningtonandson.com/contact.html
[Wed Aug 25 10:21:47 2010] [error] [client 174.55.33.42] File does not exist: /home/barrybk/benningtonandson.com/internal_error.html, referer: http://www.benningtonandson.com/contact.html


#4

That looks like a separate problem. I took a quick look, but wasn’t able to spot anything obvious.

As a general bit of advice, though, you might benefit by using Perl’s built-in CGI library (CGI.pm) instead of your own tools.