What would you expect this to emit?
my $qr = qr/f/;
print qr/[#]$qr/x;
And given the actual (surprising?) result of that, what would you expect this to emit?
my $qr = qr/(f)/;
print "#f" =~ m/[#](f)/x;
print "#f" =~ m/[#]$qr/x;
I get the same results for Perl 5.8.6, 5.8.8 and 5.9.5.
seems to be a bug (Score:1)
looks like a bug to me. somehow the interpolation stops at the first # found.
% steph@ape (/home/stephan) %
% cat t1.px
#!
my $qr = qr/f/;
print qr/$qr[#]$qr/x;
my $qr2 = qr/f/;
print qr/[b]$qr2/x;
% steph@ape (/home/stephan) %
% perl -w t1.px
(?x-ism:(?-xism:f)[#]$qr)(?x-ism:[b](?-xism:f))
Re: (Score:1)
No, it’s not really a bug. An unescaped hashmark always starts a comment in patterns where
/xapplies. If the hashmark were backslash, it would produce the result that Chris probably expected.There is a definite argument to make that it’s counterintuitive, though. Whitespace in character classes is significant even under
/x, so one would expect comments (which are usually thought of as a special kind of ignorable whitespace) would not be allowed in the middle of a character class.Re: (Score:1)
Re: (Score:1)
Ack. Yeah, definitely a bug then. Seems different parts of the regex parser have different ideas of when they’re inside a comment, or something like that.
Did you write to p5p?
Re: (Score:1)