Wednesday, 24 September 2008

The evilness of empty files

I am learning the hard way that it does pay to check that your programs do output what you expect every time they are run! In this most recent case, I have submitted jobs to the "farm" and have had a whole bunch of files created. Trouble is, some of these files are empty =(

Next time, at the end of every function that outputs to a file, I should put a check to ensure the file is not empty ... except in explicit cases where that is an expected outcome:

sub save_manipulation_in_outfile {
...
if ( ! -s $outfile ) {
confess "Output file ($outfile) is empty"
}
return $outfile
}

No comments: