Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Globs and globals

by BrentDax (Hermit)
on Jan 25, 2005 at 18:40 UTC ( [id://424986]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Globs and globals
in thread Globs and globals

Odd--you're right, though I can't figure out why. The docs seem to say that you get a new glob when you localize:

The construct local *name; creates a whole new symbol table entry for the glob "name" in the current package. That means that all variables in its glob slot ($name, @name, %name, &name, and the "name" filehandle) are dynamically reset.

In any case, the following does work correctly:

open(S1, "/dev/null"); $a=*S1{IO}; { local(*S1); open(S1, "/dev/null"); $b=*S1{IO}; } print "$a $b\n";
IO::Handle=IO(0x101536f8) IO::Handle=IO(0x1013cdec)

=cut
--Brent Dax
There is no sig.

Replies are listed 'Best First'.
Re^4: Globs and globals
by Eyck (Priest) on Jan 26, 2005 at 06:34 UTC

    Interesting, your code works, although I would expect it not to. I haven't seen this excerpt in documentation about local and globs so it's a bit of surprise for me, thanks.

    There must be something about dual nature of globs - whatever experiment you devise it proves your theory, even if it contradicts other experiments.

      I think it may be that local *glob localizes the contents of *glob, not the glob itself. The docs could be read to support that.

      Or maybe it's just that the superposition-like nature of globs means that their behavior is governed by the Heisenburg Uncertainty Principle. Yeah, that's it...

      =cut
      --Brent Dax
      There is no sig.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-19 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found