Afaik it really is a glob. Just one that doesn't live in the package namespace (and thus it has no name) but an anonymous one just like the rest of the lexically scoped vars.

Partly true. With open my $foo, $file, $foo is a reference to a glob, and the glob is not anonymous, because globs can only be in a package. The glob reference $foo can be dereferenced in a normal fashion: *$foo. With *$foo, you'll have a normal glob, like all others. Globs have a string representation that happens to be an asterisk, followed by namespace :: name.

Consider:

#!/usr/bin/perl -l { open my $foo, '>', $$ or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo print $foo "Test"; # Test > $$ } # The scope has ended. Because the lexical dies, the file is closed. # The (normally unreachable because of its invalid name) glob # *main::$foo still exists, because globals just don't die. # And they lived happily ev^U


Writing this, I thought of what would happen if I created a new lexical scope in the already existing bare block. Would the glob clash? I tried:
{ open my $foo, '>', $$ or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo print $foo "Test"; # Test > $$ { open my $foo, '>',"$$.z" or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo <-- !!!!! print $foo "Test"; # Test > $$ } }
I cannot explain this. The glob has the same stringification, but actually is another glob? Is it local()ized internally?

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk


In reply to Re: Re: (Ovid) Re: I just realized that FILEHANDLES violate use strict by Juerd
in thread I just realized that FILEHANDLES violate use strict by princepawn

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.