in reply to (tye)Re2: Wierd filehandle call
in thread Wierd filehandle call

Good point about C code expecting the fd to still be 2.

The edge case is not as bad a problem as you stated because I used local (not my because I was localizing a glob). However that does explain why the person only returned the IO part of the glob. (Of course I just store my filehandles in lexical variables.)

And I don't understand why you think that properly closing the filehandle. I just do not issue a close anywhere, but instead store the glob in a lexical variable, and when the last reference to the open filehandle goes away, the close will happen. Or in old-style Perl you just use local on your typeglobs and again it works just fine.

At least it works fine for as long as Perl keeps its reliable destruction semantics around...

Replies are listed 'Best First'.
(tye)Re3: Wierd filehandle call
by tye (Sage) on Apr 04, 2001 at 22:43 UTC

    As for closeing, I don't think *STDERR will ever go out of scope so I don't think anything will be closed until global destruction.

    Also, there are good reason to explicitly close (for example, to check for an error that might indicate a full file system prevented a buffer from being flushed).

            - tye (but my friends call me "Tye")