http://www.perlmonks.org?node_id=1154412

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.
CHECK { my $datapos = tell main::DATA; seek main::DATA,0,0; @lines =<main::DATA>; seek main::DATA, $datapos,0; } __DATA__ whatever

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
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!