Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am directing the output to a file. It is getting directed, but not at the same time. every time i click on refresh button the size of file gets increased. i have declared open and select at the beginning of the program before all the Print statements. i am using this to write to a file. open(RSCrpt,">rscrpt.txt"); $old_fh = select(RSCrpt); select ($old_fh); . . print RSCrpt " ...... "; . . . close(RSCrpt); I want the entire output written to a file simultaneously.

Replies are listed 'Best First'.
Re: Writing to a file ??
by Cine (Friar) on Aug 24, 2001 at 02:45 UTC
    I'm not sure what you want... You can never get a whole file written simultanious, the harddisk isnt fast enough. But if you want all you output to be done in one line of code, you have to save the output in a scalar and when you have everything ready you open your outfile,write this single scalar to your file and close your file again. This is the closets to simutanious you'll get...

    T I M T O W T D I
      Thanx for ur time. Even if writes slowly to the file, it doesn't write fully. It cuts some line. ????????
        This shouldnt happen under normal circumstances. It could happen if you write over a network and it drop packages, but it is unlikely anyway.

        It is far more likely that you made an error in your script and it fails to print everything, Try posting it.

        T I M T O W T D I