http://qs321.pair.com?node_id=252454


in reply to How to goto new sub if file empty?

If the file is empty, the first attempt to read from it returns false (undef) and you never execute the body of the while loop. Your call of &stopit is inside that body so it never gets called. You can check for an empty file with eof before executing the while.

open(FILE, "links.dat") || die "Can't open file!"; flock(FILE, 2) || die "Can't lock file!"; stopit if eof FILE; while ($line = <FILE>) { ....
90% of every Perl application is already written.
dragonchild