in reply to Re: -z file test operator
in thread -z file test operator
close (BADSYMS); if (-z BADSYMS ) { unlink "BADSYMS.out" or die ("Cant delete BADSYMS.out"); print "hi"; } else { print "Bad symbols contained in BADSYMS.out\n"; }
What happens now is when the file is zero or not zero, the if part is skipped, and it goes straight to the else. When the file is non-zero a message is returned:
Stat on unopened file <BADSYMS> at test.pl line 317
The filenames are assigned at the start of the script
unless (open (BADSYMS, ">BADSYMS.out")) { die ("Can't open output file BADSYMS.out\n"); }
This isn't in a loop as such, the script runs and the file maybe written to, if it isn't and therefore is empty, I want to delete it. If it is written to I want the print statement to output the name.
Thanx, Martin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: -z file test operator
by tachyon (Chancellor) on Aug 30, 2001 at 23:20 UTC |