Next | Program Repair Shop | 48 |
sub CreateOutputDir { my $dir = shift; print "Creating DIR: $dir\n"; if (mkdir $dir, 0777) { print "Success! \n"; } else { print "Fail! : $! \n"; } }
I don't want to belabor the obvious, but I really wonder about those prints
What if it does fail? Is it appropriate to just go ahead?
What about the Creating messages? Useful? Probably not.
Functions that blather can be nice
Until the day you want them to shut up
Printing diagnostics to STDOUT is easy
But STDERR was invented for a reason
Perhaps:
sub CreateOutputDir { my $dir = shift; mkdir $dir, 0777 or die "Couldn't make dir $dir: $!"; }
Next | Copyright © 2002 M. J. Dominus |