I was checking to see how in perl can one quickly test
for a file which exists but is empty and found an example so I
wrote the following code which seems to work beautifully but it
looks a little different compared to some things I have seen so
I am asking whether it could have unintended consequences. Code
follows:

if ( !-z '/usr/home/automation/power' ) {

    #mail /usr/home/automation/power
    system("mail -s \"Power Issues\" toptendhcp </usr/home/automation/power");
}
else {
    #no POE problems
    system("mail -s \"No Power Issues\" toptendhcp </tmp/nothing2report.txt");
}

        The -z test reminds me a bit of shell scripting when one
needs to test whether a string is empty or not. If this is safe,
it is a really nice way to test files for emptiness.
Thank you.

        Martin McCormick

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to