in reply to Re: Testing if a .txt file contains any data
in thread Testing if a .txt file contains any data

<petpeeve>THERE SHALL NEVER BE AN ELSE AFTER EXIT OR RETURN!!!</petpeeve>

my $wordlist = 'wordlist.txt'; if (! -s $wordlist) { print "File is empty\n"; exit 0; } # NO ELSE HERE! # your code goes here

An else is only useful if code is executed after the if/else for BOTH branches. As the first branch is exiting, the "common" code is never executed and the else is only causing unneeded clutter indent and might confuse the reader.


Enjoy, Have FUN! H.Merijn