in reply to That nagging feeling and the little voice in the back of your head
I would probably have done some statistical analysis on which extensions were the most common and use that extension in the first check. I'm also not sure whether I would have used a match or not: normally I would use eq in these cases.sub dummy_ad { my $file_ext = lc $_[0]; if ($file_ext =~ m/gif/) { print "$DUMMY_GIF\n"; } elsif ($file_ext =~ m/jpg|jpeg/) { print "$DUMMY_JPG\n"; } elsif ($file_ext =~ m/png/) { print "$DUMMY_PNG\n"; } else { print "$DUMMY_HTM\n"; } }
In any case, I think that too much laziness was the real cause of the problem here. Something, I must admit, I also have been guilty of at times and which I try to prevent exactly because of these kinds of problems.
Glad though that the problem was fixed. There's nothing more troubling than that nagging feeling that your bug fixing was not good enough. And you don't want that in the holiday season!
Merry XMas!
Liz
Update:
Just realized I would have probably used a hash lookup if I could have used eq to check extensions:
%DUMMY_AD = ( gif => "$DUMMY_GIF\n", jpg => "$DUMMY_JPG\n", jpeg => "$DUMMY_JPG\n", png => "$DUMMY_PNG\n", ); sub dummy_ad { print $DUMMY_AD{lc $_[0]} || "$DUMMY_HTM\n"; }
|
|---|