If it is a bug, it's been fixed.
(Paul had used 5.8.5, where the problem did not appear.)
I did some further poking at the problem with 5.8.0 (below). From what
I see there, there may still be a bug with 5.8.5. I'm not that familiar
with perl's UTF-8 handling, so bear with me if I misstate something
here... The regex debug information indicates that UTF-8 came into play
(for the problem case). I believe UTF-8 was enabled by default for
5.8.0 and backed out with 5.8.1. So 5.8.5 may have the bug, but it
could be masked since UTF-8 isn't enabled.
Ed
$ cat crud
#!/usr/local/bin/perl
use strict;
use warnings;
use re 'debug';
my $a = 'fuBar'; my $a_new = qx(echo -n $a);
my $b = 'Bar$';
if ( $a eq $a_new ) {
print "===> \$a eq \$a_new is true\n";
}
print "===> (\$a vs. \$b ) $a =~ /$b/ ...\n";
if ( $a =~ /$b/ ) {
print "===> match\n";
} else {
print "===> no match?!\n";
}
print "===> (\$a_new vs. \$b ) $a_new =~ /$b/ ...\n";
if ( $a_new =~ /$b/ ) {
print "===> match\n";
} else {
print "===> no match?!\n";
}
print "===> (\$a_new vs. Bar\$) $a_new =~ /Bar\$/ ...\n";
if ( $a_new =~ /Bar$/ ) {
print "===> match\n";
} else {
print "===> no match?!\n";
}
$ ./crud
Compiling REx `Bar$'
size 4 Got 36 bytes for offset annotations.
first at 1
rarest char B at 0
1: EXACT <Bar>(3)
3: EOL(4)
4: END(0)
anchored `Bar'$ at 0 (checking anchored isall) minlen 3
Offsets: [4]
1[3] 0[0] 4[1] 5[0]
Omitting $` $& $' support.
EXECUTING...
===> $a eq $a_new is true
===> ($a vs. $b ) fuBar =~ /Bar$/ ...
Compiling REx `Bar$'
size 4 Got 36 bytes for offset annotations.
first at 1
rarest char B at 0
1: EXACT <Bar>(3)
3: EOL(4)
4: END(0)
anchored `Bar'$ at 0 (checking anchored isall) minlen 3
Offsets: [4]
1[3] 0[0] 4[1] 5[0]
Guessing start of match, REx `Bar$' against `fuBar'...
Found anchored substr `Bar'$ at offset 2...
Starting position does not contradict /^/m...
Guessed: match at offset 2
===> match
===> ($a_new vs. $b ) fuBar =~ /Bar$/ ...
Compiling REx `Bar$'
size 4 Got 36 bytes for offset annotations.
first at 1
rarest char B at 0
1: EXACT <Bar>(3)
3: EOL(4)
4: END(0)
anchored utf8 `Bar'$ at 0 (checking anchored isall) minlen 3
Offsets: [4]
1[3] 0[0] 4[1] 5[0]
UTF-8 regex...
UTF-8 target...
Guessing start of match, REx `Bar$' against `fuBar'...
Did not find anchored substr `Bar'$...
Match rejected by optimizer
===> no match?!
===> ($a_new vs. Bar$) fuBar =~ /Bar$/ ...
Matching REx `Bar$' against `fuBar'
Setting an EVAL scope, savestack=9
2 <fu> <Bar> | 1: EXACT <Bar>
5 <fuBar> <> | 3: EOL
5 <fuBar> <> | 4: END
Match successful!
===> match
Freeing REx: `"Bar$"'
Freeing REx: `Bar$'
Freeing REx: `"Bar$"'
$