While I think that suggestions by
pc88mxer and
betterworld are the way to go, I can't help but wonder about the philosophical aspects of the issue :)
All scripts make certain base assumptions in order to function. A stable filesystem to act on is a good base assumption. If NFS is erratic, there's not much the script can do in terms of handling that kind of catastrophic failure. The partial damage would have already occurred in previous
while (<>) iterations, anyway.
So, would it be useful to put out a warning that an unexpected critical error has just happened? Yes, that would be nice. But how far do we go?
Will this succeed as a new Perl idiom:
while (<>) {
unless ($!) {
# do actual stuff here
}
}
How far do we go down the path of paranoia just to make the script bullet-proof?
Update: Thanks for pointing my mistake out, ikegami. Still, I'd like to know how much is too much when it comes to error checking of this nature.