I'm trying to work out why this error is coming up in a Perl script:
A fatal error has occured:
Modification of a read-only value attempted at (eval 7) line 10.
Please enable debugging in setup for more details.
When I run it with this from the command line:
perl -d admin.cgi
the point it dies is:
<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font></p><blockquote><pre>Modification of a read-only value attempted at (eval 14)[/home/user/public_html/cgi-bin/links/admin/GT/AutoLoader.pm:128] line 10.
</pre></blockquote><p><font face='Tahoma,Arial,Helvetica' size=2>Please enable debugging in setup for more details.</font></p>
Modification of a read-only value attempted at (eval 14)[/home/user/web/example.com/public_html/cgi-bin/links/admin/GT/AutoLoader.pm:128] line 10.
Debugged program terminated. Use q to quit or R to restart,
Looking at the AutoLoader.pm file, I see this on line 128:
eval "package $pkg;\n#line $linenum$pkg\::$func\n$COMPILE->{$func}";
If I add in a bit more debug:
print "FOO: $pkg ($func)\n";
I then see this when running:
FOO: GT::Template (_call_func)
FOO: GT::CGI (html_escape)
FOO: GT::Base (in_eval)
<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font></p><blockquote><pre>Modification of a read-only value attempted at (eval 7) line 10.
</pre></blockquote><p><font face='Tahoma,Arial,Helvetica' size=2>Please enable debugging in setup for more details.</font></p>
Modification of a read-only value attempted at (eval 7) line 10.
The script worked fine the whole of yesterday, and I don't think I've changed anything that would cause this- so I'm at a bit of a loss.
UPDATE: After some more digging, I've found its coming from this line in another module:
my $output = $code->($self);
$code
seems to be coming from a bit above:
my $root = $self->{root};
my $full_file = $self->{root} . '/' . $template;
my ($code, $dont_save, $files) = $self->{opt}->{print} == 2
? @{$FILE_CACHE_PRINT{$full_file}}{qw/code dont_save files/}
: @{$FILE_CACHE{$full_file}}{qw/code dont_save files/};
UPDATE 2:
As requested, here is the output from print STDERR qq|package $pkg;\n#line $linenum$pkg\::$func\n$COMPILE->{$func}\n|;
:
package GT::Base;
#line 538GT::Base::in_eval
sub in_eval {
# -------------------------------------------------------
# Current perl has a variable for it, old perl, we need to look
# through the stack trace. Ugh.
#
my $ineval;
if ($] >= 5.005 and !MOD_PERL) { $ineval = defined($^S) ? $^S : (stack_trace('GT::Base',1) =~ /\(eval\)/) }
elsif (MOD_PERL) {
my $stack = stack_trace('GT::Base', 1);
$ineval = $stack =~ m{
\(eval\)
(?!
\s+called\ at\s+
(?:
/dev/null
|
-e
|
/\S*/(?:Apache2?|ModPerl)/(?:Registry(?:Cooker)?|PerlRun)\.pm
|
PerlHandler\ subroutine\ `(?:Apache2?|ModPerl)::Registry
)
)
}x;
}
else {
my $stack = stack_trace('GT::Base', 1);
$ineval = $stack =~ /\(eval\)/;
}
return $ineval;
}
<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font></p><blockquote><pre>Modification of a read-only value attempted at (eval 7) line 10.
</pre></blockquote><p><font face='Tahoma,Arial,Helvetica' size=2>Please enable debugging in setup for more details.</font></p>
Modification of a read-only value attempted at (eval 7) line 10.