Re: [MacPerl-AnyPerl] Terminating a perl script from the shell cleanly?

[email protected] (Ronald J Kimball) Wed, 7 Feb 2001 13:40:40 -0500
Newsgroups perl.macperl.anyperl
Message-ID <[email protected]>
On Wed, Feb 07, 2001 at 01:22:18PM -0500, Jim Correia wrote:
> 
> In particular, I want to nuke a program in mid-execution and have perl
> clean up as best as it can at this point, which includes flushing the
> buffers of any open files.

The easiest solution is to just turn on autoflush when the file is opened.

use IO::File;           # get access to filehandle methods

open(OUTPUT, ">out") or die "Can't open 'out': $!\n";

OUTPUT->autoflush(1);   # equivalent to setting $| = 1 for OUTPUT


Ronald