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__
-
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.
|