Perl Bug 3 - PL_origfilename not updated properly in error messages


perl version: 5.005_03, 5.6.0

Perl internals question: changing PL_origfilename in script

The perl interpretor (or just the yacc?) allows you to redefine the filename and/or line number that perl believes it is parsing using the common [# <line> "<file>"] preprocessor format.

Unfortunately, this doesn't seem to carry over to the perl internal variable PL_origfilename, so some errors (syntactical?) will use the redefined filename, and some errors use the real file.

As an example, consider the following file (including the '#' line):

-- File: foo ------------
# 1 "somefile"
print "Here is some perl\n";
$error_here = ;
-------------------------
Then try these commands:
-------------------------
% perl foo
syntax error at somefile line 2, near "= ;"
Execution of foo aborted due to compilation errors.
% cat foo | perl
syntax error at somefile line 2, near "= ;"
Execution of - aborted due to compilation errors.
-------------------------
The 'compilation errors' using the perl internal variable PL_origfilename, but the syntax error uses the [# <line> "<file>"] information.