Mailing List Archive

/(?i)pattern/ problem with array of patterns.
Hi-
The (?i) construct for case-insensitive pattern matching does not
work correctly:
If you set up an array of patterns, one of which is made case-insensitive
using (?i), then SUBSEQUENT PATTERNS in the array are ALSO rendered
case-insensitive.

Run the following test script:

-----------------------------------cut here---------------------------------
#!/usr/local/bin/perl

@patterns1=(
'(?i)dummy',
'UPPERCASE',
);

@patterns2=(
'UPPERCASE',
'(?i)dummy',
);

@string=(
"uppercase pattern.\n",
"UPPERCASE pattern.\n",
);


print "Patterns1:\n";
foreach $pattern (@patterns1) {
foreach (@string) {
print "Matched the pattern $pattern. String= $_" if (/$pattern/);
}
}

print "Patterns2:\n";
foreach $pattern (@patterns2) {
foreach (@string) {
print "Matched the pattern $pattern. String= $_" if (/$pattern/);
}
}
-----------------------------------cut here---------------------------------

When I run this, I get the output

Patterns1:
Matched the pattern UPPERCASE. String= uppercase pattern.
Matched the pattern UPPERCASE. String= UPPERCASE pattern.
Patterns2:
Matched the pattern UPPERCASE. String= UPPERCASE pattern.

The only difference between @patterns1 and @patterns2 is the order of
the elements!

I have reproduced this bug on several different machines using perl5.001m.



---Mark