This example shows that neither \*main::DATA nor \*last_pckg::DATA can be reliably used without further information.
We either need a mechanism to get the real filehandle of the current file (maybe thru B ?) or a way to identify the file associated to those filehandles (for check against $0)
lanx@nc10-ubuntu:/tmp$ cat no_data.pl use wrong_data; print <DATA>; lanx@nc10-ubuntu:/tmp$ cat wrong_data.pm 1; __DATA__ wrong main::DATA lanx@nc10-ubuntu:/tmp$ perl -MO=Deparse no_data.pl use wrong_data; print <DATA>; __DATA__ wrong main::DATA no_data.pl syntax OK lanx@nc10-ubuntu:/tmp$ perl no_data.pl wrong_main::DATA
for completeness: The deparsed code will produce the same results now in this special case!
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
In reply to Re^4: Why shows B::Deparse __END__ as __DATA__? (BUG #3)
by LanX
in thread Why shows B::Deparse __END__ as __DATA__?
by karlgoethebier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |