Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
if (-z BADSYMS ) { (`rm BADSYMS.out`); } else { print ("Bad symbols contained in BADSYMS.out\n"); }
I want to test to see if the file is empty and if so remove it. Otherwise I want to print the name of it.
I am currently opening the file at the beginning of the script, as opposed to opening it only if the pattern is matched.
Am I using the -z incorrectly? I have also tried the -s by assigning it to a scalar and seeing if ==0 but this hasn't worked correctly either.
Any thoughts?
Thanks, Martin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: -z file test operator
by tomhukins (Curate) on Aug 30, 2001 at 16:49 UTC | |
by tilly (Archbishop) on Aug 30, 2001 at 17:04 UTC | |
by Anonymous Monk on Aug 30, 2001 at 17:08 UTC | |
by Anonymous Monk on Aug 30, 2001 at 17:32 UTC | |
by Hofmator (Curate) on Aug 30, 2001 at 17:41 UTC | |
|
Re: -z file test operator
by Zaxo (Archbishop) on Aug 30, 2001 at 17:30 UTC | |
by Anonymous Monk on Aug 30, 2001 at 18:19 UTC | |
by tachyon (Chancellor) on Aug 30, 2001 at 23:20 UTC | |
|
Re: -z file test operator
by tachyon (Chancellor) on Aug 30, 2001 at 17:24 UTC | |
|
Re: -z file test operator
by stefan k (Curate) on Aug 30, 2001 at 16:55 UTC |