Hi, now I am using:
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


In reply to Re: Re: -z file test operator by Anonymous Monk
in thread -z file test operator by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.