Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm pretty sure that DATA is only an alias of anther filehandle pointing to the current code...
Why do you think so? It seems such a thing doesn't exist:
for ( values %main:: ) { my $io = *{$_}{IO} or next; my $name = *{$_}{NAME}; if ( defined fileno $io ) { printf "fileno of %6s is %d\n", $name, fileno $io; } else { print "($name is a virtual handle)\n"; } }
output:
fileno of stdin is 0 fileno of stdout is 1 fileno of STDIN is 0 fileno of STDOUT is 1 fileno of stderr is 2 fileno of STDERR is 2 (ARGV is a virtual handle)
and if we add __DATA__ to the file:
fileno of STDERR is 2 fileno of STDIN is 0 fileno of STDOUT is 1 fileno of stdout is 1 fileno of stdin is 0 (ARGV is a virtual handle) fileno of DATA is 3 fileno of stderr is 2
So only __DATA__ is opened on fd 3... maybe there is some secret pro tech, but I suspect there isn't and then your best option is probably to just open __FILE__

In reply to Re: 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 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? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2022-05-23 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?