Open p5pRT opened 17 years ago
As far as I know\, the effect of a \U\, \L or \Q is cancelled by the first \E encountered\, and no nesting happens.
And as long as you use \U and \L\, it works this way. However\, \Q seems to behave differently. \Q seems to match with a matching \E\, and work from the inside out.
I don't know what "\Q-\Q-\E-\E-" is supposed to be\, both '\-\---' and '\-\\Q\---' have some logic (although the former would be my favourite); however\, currently "\Q-\Q-\E-\E-" equals '\-\\\-\--'\, which seems plain wrong to me.
The following tests fail 5 times (tests 2\, 5\, 7\, 8\, and 9)\, while I think they should all pass.
#!/usr/bin/perl
use strict; use warnings; no warnings 'syntax';
use Test::More tests => 9;
is "Aa-\UBb-\LCc-\EDd-\EEe-"\, 'Aa-BB-cc-Dd-Ee-'\, '\L after \U'; is "Aa-\UBb-\QCc-\EDd-\EEe-"\, 'Aa-BB-CC\-Dd-Ee-'\, '\Q after \U'; is "Aa-\UBb-\UCc-\EDd-\EEe-"\, 'Aa-BB-CC-Dd-Ee-'\, '\U after \U';
is "Aa-\LBb-\UCc-\EDd-\EEe-"\, 'Aa-bb-CC-Dd-Ee-'\, '\U after \L'; is "Aa-\LBb-\QCc-\EDd-\EEe-"\, 'Aa-bb-cc\-Dd-Ee-'\, '\Q after \L'; is "Aa-\LBb-\LCc-\EDd-\EEe-"\, 'Aa-bb-cc-Dd-Ee-'\, '\L after \L';
is "Aa-\QBb-\UCc-\EDd-\EEe-"\, 'Aa-Bb\-CC\-Dd-Ee-'\, '\U after \Q'; is "Aa-\QBb-\LCc-\EDd-\EEe-"\, 'Aa-Bb\-cc\-Dd-Ee-'\, '\L after \Q'; is "Aa-\QBb-\QCc-\EDd-\EEe-"\, 'Aa-Bb\-Cc\-Dd-Ee-'\, '\Q after \Q';
__END__
On Mar 23 2007\, Abigail wrote:
As far as I know\, the effect of a \U\, \L or \Q is cancelled by the first \E encountered\, and no nesting happens.
And as long as you use \U and \L\, it works this way. However\, \Q seems to behave differently. \Q seems to match with a matching \E\, and work from the inside out.
I don't know what "\Q-\Q-\E-\E-" is supposed to be\, both '\-\---' and '\-\\Q\---' have some logic (although the former would be my favourite); however\, currently "\Q-\Q-\E-\E-" equals '\-\\\-\--'\, which seems plain wrong to me.
I think this is all covered in L\<perlop/"Gory details of parsing quoted constructs">. Basically\, everything after \Q is double-quote interpolated before escaping\, which includes interpolating \Q sequences. So these are all equivalent:
print "\Q-\Q-\E-\E"; print quotemeta("-\Q-\E-\E"); print quotemeta("-" . "\Q-\E-\E"); print quotemeta("-" . quotemeta("-\E") . "-\E");
-- Rick Delaney rick@bort.ca
The RT System itself - Status changed from 'new' to 'open'
Rick Delaney a écrit :
On Mar 23 2007\, Abigail wrote:
As far as I know\, the effect of a \U\, \L or \Q is cancelled by the first \E encountered\, and no nesting happens.
And as long as you use \U and \L\, it works this way. However\, \Q seems to behave differently. \Q seems to match with a matching \E\, and work from the inside out.
I don't know what "\Q-\Q-\E-\E-" is supposed to be\, both '\-\---' and '\-\\Q\---' have some logic (although the former would be my favourite); however\, currently "\Q-\Q-\E-\E-" equals '\-\\\-\--'\, which seems plain wrong to me.
I think this is all covered in L\<perlop/"Gory details of parsing quoted constructs">. Basically\, everything after \Q is double-quote interpolated before escaping\, which includes interpolating \Q sequences. So these are all equivalent:
print "\\Q\-\\Q\-\\E\-\\E"; print quotemeta\("\-\\Q\-\\E\-\\E"\); print quotemeta\("\-" \. "\\Q\-\\E\-\\E"\); print quotemeta\("\-" \. quotemeta\("\-\\E"\) \. "\-\\E"\);
I think the only real bug in all this is
% perl -le "print qq{\Un\lext}" NEXT
According to the docs\, that should print "NeXT". I cam see where and why in the parser it comes out like this\, but at this late stage of the game I think it would be better to amend to documentation to say that \l and \u are ignored if a \U or \L are in force.
There's a bug (#9360) open on this issue.
David
There's a bug (#9360) open on this issue.
For reference: in github this is actually issue #5467
Migrated from rt.perl.org#42043 (status was 'open')
Searchable as RT42043$