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!

Replies are listed 'Best First'.
Re: A story of two glob()s
by nimdokk (Vicar) on May 04, 2005 at 14:51 UTC
    I think this points out the fact that when changes are made, no matter how seemingly minor, thorough re-testing should be done prior to moving those changes into production. I've been having this go-round for the last 5 months with an area that made several "minor" changes to a process and it hasn't run right since then. Honestly, the whole process is quite the Rube Goldberg contraption. I didn't come up with it, just inherited it and have to support it (*heavy sigh*).
      Indeed. The original script had been thoroughly tested and the change was so appearently innocent that we put the modified one directly into production. That was a big mistake...