in reply to Re: print() on closed filehandle
in thread print() on closed filehandle

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

Replies are listed 'Best First'.
Re^3: print() on closed filehandle
by ambrus (Abbot) on May 04, 2011 at 09:37 UTC

    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.

Re^3: print() on closed filehandle
by LanX (Saint) on May 04, 2011 at 09:38 UTC
    Exactly! That is his point!

    Cheers Rolf

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

Re^3: print() on closed filehandle
by tchrist (Pilgrim) on May 05, 2011 at 13:58 UTC
    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. 😒