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 |
In reply to Re: How to goto new sub if file empty?
by pfaut
in thread How to goto new sub if file empty?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |