This is not strictly perl specific, but I hope it is of some interest here. It's the story of a somewhat trivial mistake I made that though took me the best part of an our or so to understand and cure - in a production script, what's worst!

Well, in this script I got a list of files with a simple glob() since it was convenient for various reasons. Note that I did some more filtering with a more fine-tuned regex as well, so that I may have done a readdir() myself or a glob '*'. However that's not what I did in the first place.

Now, it happened that the format of the filenames changed in the meanwhile, so I changed both the regex and a line of code like

my @logs=glob $pat;
to
my @logs=map glob($_), $pat1, $pat2;
(well, not exactly, but that gives the idea.)

What happened then? That after these appearently innocent modifications, that long tested and trusted program began to spit out severe errors with quite unpleasant side effects (due to the nature of the other actions the program takes).

What was the problem? Simply, as it later occurred to me, that I had duplicates in @logs and since one of the actions taken by the program is to move such files around, well, it happened that I did things like statting inesistent files and stuff like that...

Well, the problem is resolved now. I just felt like sharing this story of a bad mistake I made. I'm not really sure it would help, for I'm sure I will continue to make stupid mistakes and, hey, I bet you will as well! <g> However... be cautious!


In reply to A story of two glob()s by blazar

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.