Syntactic Confectionery Delight | |
PerlMonks |
Introspecting the current Perl file via DATA, even w/o DATA?by LanX (Saint) |
on Feb 04, 2016 at 18:18 UTC ( [id://1154412]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
I'm using this code to read the current Perl file into @line to be able to enrich my error messages with the originating code line.
This works only if there is a __DATA__ line, otherwise the filehandle DATA doesn't exist. I'm pretty sure that DATA is only an alias of anther filehandle pointing to the current code... Any idea how to get this filehandle? (don't want to explicitly open $0 again for reasons of complexity and performance)
Cheers Rolf
Back to
Seekers of Perl Wisdom
|
|