in reply to Do I need local $

$| (see perlvar) affects the currently selected filehandle. You might have better luck with IO::File, which is in the core as of 5.6.1 (or earlier).

I'm not sure what you're asking, if that doesn't help.

Replies are listed 'Best First'.
Re: Re: Do I need local $
by rjray (Chaplain) on Feb 18, 2002 at 07:46 UTC

    If you were to use IO::File, you will find that the object that you get for the filehandle has a method available called autoflush(). This will set that property on the filehandle. Also, in your DESTROY method for your log class, you can simply undef the object reference, and let its own DESTROY method handle the closing of the file and the requisite clean-up.

    --rjray

      Infact I would be inclined to subclass IO::File ... that way you get to use all the methods of IO::File in your class :)

      /J\

      Thanks for your answer, I saw this post in a newsgroup...

      Does this mean that the file will only close when the application closes or if I manually call it?

      -----------------------------------------------------------

      > You mentioned the IO::File DESTROY method trying to cleanup the file
      > descriptors ...
      >
      > .. DESTROY method is coded to be a no-op, leaving any clean up to
      > perl's handling of the closing of a file.

      Oops, busted.

      IO::File's DESTROY is a no-op in perl 5.6 (inherited from IO::Handle).

      I didn't actually look at the DESTROY method for IO::File. I had just
      assumed that the object was being destructed properly. (Well, it wasn't
      all assumption ... there was a little empirical testing going on too.
      :-) My phrasing was mainly meant to express, "high-level cleanup seems
      to be coded correctly".

      Sorry for the confusion.



      -- Robert Trace