Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Because the filepointer is in sync with the parsing phases of Perl
Not necessarily, no... Let's see
BEGIN { print "BEGIN\n"; } UNITCHECK { print "UNITCHECK\n"; } CHECK { print "CHECK\n"; } INIT { print "INIT\n"; } print "MAIN\n";
Let's strace it (Debian Jessie, Perl 5.22)
open("t.pl", O_RDONLY) = 3 ... read(3, "BEGIN {\n print \"BEGIN\\n\";\n}\nU"..., 8192) = 146 write(1, "BEGIN\n", 6) = 6 read(3, "", 8192) = 0 close(3) = 0 write(1, "UNITCHECK\n", 10) = 10 write(1, "CHECK\n", 6) = 6 write(1, "INIT\n", 5) = 5 write(1, "MAIN\n", 5) = 5
Note that the file is closed right after BEGIN (and before UNITCHECK). So no handle to it can exist. But, if we add
__DATA__ whatever
that it changes a bit...
open("t.pl", O_RDONLY) = 3 ... read(3, "BEGIN {\n print \"BEGIN\\n\";\n}\nU"..., 8192) = 165 write(1, "BEGIN\n", 6) = 6 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 write(1, "UNITCHECK\n", 10) = 10 write(1, "CHECK\n", 6) = 6 write(1, "INIT\n", 5) = 5 write(1, "MAIN\n", 5) = 5 ... close(3) = 0 exit_group(0) = ?
Now the file isn't closed until exit. So without __DATA__ there is no handle to the file, and the only handle (that I can find :) is DATA.

Anyway, let us know if you'll find something in perl5db.pl or somewhere else.


In reply to Re^3: Introsepcting the current Perl file via DATA, even w/o DATA? by Anonymous Monk
in thread Introspecting the current Perl file via DATA, even w/o DATA? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-18 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found