in reply to Introspecting the current Perl file via DATA, even w/o DATA?
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:
output: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"; } }
and if we add __DATA__ to the file: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)
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__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
|
---|
In Section
Seekers of Perl Wisdom