This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Why you should check for errors :)
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
What's wrong with this picture:
open(OUTFILE,">${tmpdir}${code}");
print OUTFILE $scode;
close(OUTFILE);
Well, it may not be my style. But, the biggest problem is What happens if the OUTFILE isn't created?
I ran into this when my security codes weren't working. There was no bad output, other than a glimpsing error that I saw on a screen saying that there was something up with the print OUTFILE $scode line.
The problem was that the $tmpdir had gotten bad permissions.
It would be a lot nicer if we had:
open OUTFILE, ">${tmpdir}${code}" or die "I guess I should tell someone that this didn't work. opening ${....}: $!";
I always like to run my scripts with -w, use strict; etc... like a good boy. This had me change mt-scode.cgi too:
#my $cookie = $cgi->cookie(-name=>'code',-value=>$code);
$cookie doesn't seem to be used anymore and -name=>code was bare instead of quoted anyway.
Now everyone is happy, and the codes are back :)