Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by LanX (Saint)
on Oct 12, 2014 at 12:45 UTC ( [id://1103541]=note: print w/replies, xml ) Need Help??


in reply to Re: Why shows B::Deparse __END__ as __DATA__?
in thread Why shows B::Deparse __END__ as __DATA__?

and here a real bug:

lanx@nc10-ubuntu:/tmp$ cat end_pkg.pl print <DATA>; package TST; 1; __END__ end lanx@nc10-ubuntu:/tmp$ perl -MO=Deparse end_pkg.pl print <DATA>; package TST; '???'; end_pkg.pl syntax OK lanx@nc10-ubuntu:/tmp$ perl end_pkg.pl end lanx@nc10-ubuntu:/tmp$ perl -MB::Deparse -E 'say "$B::Deparse::VERSION +"' 0.83

update
took a look into current source of B::Deparse version 1.20 and it has the same code regarding __DATA__

Cheers Rolf

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

Replies are listed 'Best First'.
Re^3: Why shows B::Deparse __END__ as __DATA__? (BUG #2)
by LanX (Saint) on Oct 12, 2014 at 13:25 UTC
    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!

      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»

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103541]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-25 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found