Your problems are 1) you close the file handle then try to test it. 2) You can't unlink an file that has an open filehandle on many systems. This should be self explanatory code. $file is the FILE NAME. We open this file onto the FILE HANDLE called BAD. We can then read from the file through the filehandle.
$file = "bad.out"; open BAD, $file or die "Oops can't open $file Perl says $!\n" # do stuff to BAD close BAD; if ( -s $file ) { # file has size } else { # file has zero size unlink $file or die "Can't unlink $file: $!\n"; }
PS Get a login! cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Re: Re: -z file test operator
by tachyon
in thread -z file test operator
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |