in reply to Is this a logic bug or a perl bug?

The while loop uses $_, but doesn't localize it. $_ is aliased to a location in @suffix. Thus, the location in @suffix gets overwritten.

One way to solve this would be to localize $_:

{ local $_; while (<DATA>) { ... } }

Another way would be to use a different variable on the foreach:

foreach $suffix (@suffix) # Or $s, or maybe use @suffixes # or @suffixen to imply plural...

Also note, just for clarity, that DATA is a special filehandle opened to the source code after the token __DATA__. It might be a good idea to change that.

HTH...

Replies are listed 'Best First'.
Re: Re: Is this a logic bug or a perl bug?
by weltyj (Novice) on Aug 17, 2001 at 21:51 UTC
    Thanks, that works. Good tip about the DATA filehandle, I was rushing to pull all this out of a larger script and just made that up as fast as possible.