in reply to Re: Do I need local $
in thread Do I need local $

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

Replies are listed 'Best First'.
Re: Re: Re: Do I need local $
by gellyfish (Monsignor) on Feb 18, 2002 at 10:33 UTC

    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\

Re: Re: Re: Do I need local $
by Anonymous Monk on Feb 19, 2002 at 02:57 UTC
    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