I think there'e a lesson to be learnt here. I always try to program in such a way that CPU usage is at a minimum. I would therefore have programmed the sub in this way from the beginning:
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"; } }
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.

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"; }

In reply to Re: That nagging feeling and the little voice in the back of your head by liz
in thread That nagging feeling and the little voice in the back of your head by tachyon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.