Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Filehandle of the current sourcecode, pointing after last code line?

by shmem (Chancellor)
on Oct 13, 2014 at 10:28 UTC ( [id://1103608]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Filehandle of the current sourcecode, pointing after last code line?
in thread Filehandle of the current sourcecode, pointing after last code line?

Did you read the "motivation" part? :)

Yes, I did. And I can't see any bug there regarding DATA. Maybe I don't get the point.

package Quux; our $foo = "blorflydick"; print "in Quux\n"; print while <DATA>; print $foo,$/; 1; package blorflydick; print $foo,$/; __DATA__ blorf, blorf.
#!/usr/bin/perl use Foo; use Bar; use Quux; print while <DATA>; print "Foo (",fileno Foo::DATA, ")\n"; print while <Foo::DATA>; print "Bar (",fileno Bar::DATA, ")\n"; print while <Bar::DATA>; print "Symbol table Quux::\n"; print "$_ => $Quux::{$_}\n" for sort keys %Quux; print "Symbol table blorflydick::\n"; print "$_ => $blorflydick::{$_}\n" for sort keys %blorflydick::; print "Quux (",fileno Quux::DATA, ")\n"; print while <Quux::DATA>; print "ok, trying blorflydick\n"; print "blorflydick (",fileno blorflydick::DATA, ")\n"; print while <blorflydick::DATA>; package Baz; __DATA__ so this works. __END__ in Quux blorflydick blorflydick Foo (4) Foo foo foo foo Bar (5) print Bar. I told you so. Symbol table Quux:: Symbol table blorflydick:: DATA => *blorflydick::DATA Quux () ok, trying blorflydick blorflydick (6) blorf, blorf.

I think of the DATA filehandle as an alias to the fully qualified DATA filehandle with similar semantics as our, with the difference that it isn't file scoped like our variables are.

So, the blorflydick::DATA filehandle points to Quux.pm which is not a bug IMHO.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^4: Filehandle of the current sourcecode, pointing after last code line?
by LanX (Saint) on Oct 13, 2014 at 10:43 UTC
    It's a "bug" regarding B::Deparse which tries to guess which DATA handle is pointing to the end of the current file.

    Like demonstrated one can have 2 such opened handles (in main and current package) and non points to that current file.

    Cheers Rolf

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found