U
usenet
Kindly consider this sample code which illustrates my question:
#!/usr/bin/perl
use strict; use warnings;
my $rx = qr{[A-C]};
while (<DATA>) {
# print if m{[A-C]}i;
print if m{$rx}i;
}
__DATA__
ABC
abc
def
I expect both print statements to have the same functionality, the only
difference is that the second statement uses a compiled regex.
However, the second print does not match data 'abc', even though I am
using the 'i' regex modifier (whereas the first statement matches both
'ABC' and 'abc', as I expected).
How can I apply case-insensitive matching to a compiled regular
expression, without needing to do something awful like my $rx =
qr{[A-Ca-c]} ?
Thanks!
#!/usr/bin/perl
use strict; use warnings;
my $rx = qr{[A-C]};
while (<DATA>) {
# print if m{[A-C]}i;
print if m{$rx}i;
}
__DATA__
ABC
abc
def
I expect both print statements to have the same functionality, the only
difference is that the second statement uses a compiled regex.
However, the second print does not match data 'abc', even though I am
using the 'i' regex modifier (whereas the first statement matches both
'ABC' and 'abc', as I expected).
How can I apply case-insensitive matching to a compiled regular
expression, without needing to do something awful like my $rx =
qr{[A-Ca-c]} ?
Thanks!