Subject: | match vars empty when vars used in regexp |
Under Regexp::DefaultFlags, if you include a var in a capture group of a
regexp it gets matched correctly but the match var doesn't contain the
contents afterwards. *But*, a capture group containing the var *and some
other material* starts working as expected again. <boggles>
Some details:
Version 0.01 of Regexp::DefaultFlags released September 28, 2004.
perl -v:
This is perl, v5.8.7 built for i486-linux-gnu-thread-multi
(with 1 registered patch, see perl -V for more detail)
perl -V:
Locally applied patches:
SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962
uname -a:
Linux delilah 2.6.15-27-386 #1 PREEMPT Sat Sep 16 01:51:59 UTC 2006 i686
GNU/Linux
(God, I just looked at the code, this bug report is longer than the
module. What can possibly be going wrong there?!)
Tiny test file follows:
# demonstrates that Regexp::DefaultFlags != /×ms
my $string = "ef";
my $regexp = 'e';
$string =~ m/(($regexp)f)/xms;
my $expected_ef = $1; # $1 eq 'ef'
my $expected_e = $2; # $2 eq 'e'
use Regexp::DefaultFlags;
if ($string =~ m/(($regexp)f)/) { # it matches, and...
print "matched as expected, and...\n";
if ($expected_ef eq $1) { # it is, but...
print "'ef' captured ok, but...\n";
}
else {
print "expected [$expected_ef], got [$1]\n";
}
if($expected_e eq $2) { # it isn't!
print "sorry, my mistake, no problem!\n";
}
else {
print "expected [$regexp], got [$2]\n"; # $1 eq ''
}
}
else {
print "didn't match at all\n"; # doesn't happen
}