A
Anno Siegel
I am observing this strange behavior:
# prepare a string
my $str = 'aa';
$str &= 'a'; # shorten it
print "str: $str\n"; # a single "a" as expected
# $str = "$str"; # this heals the defect (if any)
# something is wrong, though
die "Ha!\n" unless $str =~ /a+$/; # this dies!
The pattern should, of course, match. Similar patterns, like /a$/ and
/a+/ do match, but /a+$/ isn't recognized. Copying the string into itself
normalizes the behavior. "use bytes" makes no difference.
Whether the bug (or am I missing something?) is in &= or the regex
engine (gasp) is anyone's guess. My money is on string-truncation
by &=. It would be rarely-exercised code, other bitwise operations
don't shorten.
Anno
# prepare a string
my $str = 'aa';
$str &= 'a'; # shorten it
print "str: $str\n"; # a single "a" as expected
# $str = "$str"; # this heals the defect (if any)
# something is wrong, though
die "Ha!\n" unless $str =~ /a+$/; # this dies!
The pattern should, of course, match. Similar patterns, like /a$/ and
/a+/ do match, but /a+$/ isn't recognized. Copying the string into itself
normalizes the behavior. "use bytes" makes no difference.
Whether the bug (or am I missing something?) is in &= or the regex
engine (gasp) is anyone's guess. My money is on string-truncation
by &=. It would be rarely-exercised code, other bitwise operations
don't shorten.
Anno