in reply to print() on closed filehandle

Perhaps you open LOG in a different package from where you print LOG?

Replies are listed 'Best First'.
Re^2: print() on closed filehandle
by ikegami (Patriarch) on May 04, 2011 at 09:31 UTC

    Why would one package's LOG affect another's?

      That's the problem, it doesn't, but maybe the OP thinks that filehandle is global so it can be used directly from another package (hard to tell without some form of telepathy), and this is the error print would give in that case.

      Exactly! That is his point!

      Cheers Rolf

        doh! Don't visit PerlMonks when tired from 12 hours of driving and a cold.

      Why would one package’s LOG affect another’s?
      Perhaps through typeglob aliasing ᴀᴋᴀ importing? *LOG = *OtherPack::LOG{IO}

      Mind you, there are handles that when used without package qualification do get auto-qualified into main:: rather than into the current package as one might otherwise expect. STDIN, STDOUT, and STDERR work that way, although stdin, stdout, and stderr are only in main::. I wouldn’t suggest using ARGV, ARGVOUT, or _, the stat-cache handle, since all are already used by Perl for their own purposes.

      But I don’t see why you couldn’t use an ENV filehandle, for example, as a sort of über-global. I don’t believe that one’s spoken for yet. The other one that appears available for such subterfuge is a SIG filehandle.

      But I don’t really suggest it: it would probably just get you talked about. 😒