$ cat foo
require 'bar';
$ cat bar
#line 3
die
$ perl foo
Died at foo line 3.
The #line directive makes perl consider bar to be the current file at
the die (in addition to changing the line number). I can't imagine a
situation where this would be desirable, so I changed it in my perl:
$ cat foo
require 'bar';
$ cat bar
#line 3
die
$ ./perl foo
Died at bar line 3.
This makes sense to me and I can't imagine what it could break.
However, it does appear in the source code that somebody created the
current behaviour purposefully, so I'm not sure.
The reason I want this is that I have a script that does install-time
modification of modules, but I want the reported line numbers to match
the original files. I could embed the filname in the installed modules
(#line 3 "filename"), but I would rather let perl print the filename
exactly as it would otherwise, and don't want to hardcode an absolute
string.
Here's what I did:
Inline Patch
--- toke.c.orig Tue Dec 21 15:40:48 1999+++ toke.c Tue Dec 21 15:40:54 1999@@ -368,8 +368,6 @@
*t = '\0';
if (t - s > 0)
PL_curcop->cop_filegv = gv_fetchfile(s);
- else- PL_curcop->cop_filegv = gv_fetchfile(PL_origfilename);
*t = ch;
PL_curcop->cop_line = atoi(n)-1;
}
Andrew
Migrated from rt.perl.org#1931 (status was 'resolved')
Searchable as RT1931$
The text was updated successfully, but these errors were encountered: