in reply to Re^2: Why shows B::Deparse __END__ as __DATA__? (BUG #1)
in thread Why shows B::Deparse __END__ as __DATA__?

and here another related bug, B::Deparse appends the wrong __DATA__ from the used module, cause of package confusion.

lanx@nc10-ubuntu:/tmp$ cat use_wrong.pl use wrongdata; print <DATA>; package TST; 1; __END__ end lanx@nc10-ubuntu:/tmp$ perl use_wrong.pl end lanx@nc10-ubuntu:/tmp$ cat wrongdata.pm package TST; 1; __DATA__ wrongdata lanx@nc10-ubuntu:/tmp$ perl -MO=Deparse use_wrong.pl use wrongdata; print <DATA>; package TST; '???'; package TST; __DATA__ wrongdata use_wrong.pl syntax OK

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

update

see Re^2: Why shows B::Deparse __END__ as __DATA__? for explanation!

Replies are listed 'Best First'.
Re^4: Why shows B::Deparse __END__ as __DATA__? (BUG #3)
by LanX (Saint) on Oct 12, 2014 at 15:26 UTC
    no_data.pl has no DATA section at all, but B::Deparse includes the part from the used module.

    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 ☆☆☆☆ :)

      "Es ist immer komplizierter." (Ludwig Marcuse)

      Thank you LanX for investigations, explanations and clarifications.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»