-
Notifications
You must be signed in to change notification settings - Fork 577
pod and comments: Note escape vs quote #23264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: blead
Are you sure you want to change the base?
Conversation
ede7f9d
to
8d8d490
Compare
This adds a bit of text about metacharacters that was missing from this introductory pod.
Fixes Perl#15221 The documentation and comments were misleading about conflating quoting a metacharacter and escaping it. Since \Q stands for quote, we have to continue to use that terminology. This commit clarifies that the two terms are often equivalent. This also adds a note that quotemeta isn't affected by locale.
Today it is more common to use the C<L<quotemeta()|perlfunc/quotemeta>> | ||
(If C<use locale> is in effect, then this depends on the current locale.) | ||
|
||
This template used to be a common paradigm, but these days it is more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really the purpose of this PR, but I think it's a little misleading to say that quotemeta "disables metacharacters special meanings" without also saying that it actually does a very similar thing to the example just above, without being locale dependent for ASCII characters. i.e. it's exactly equivalent to s/([^A-Za-z_0-9])/\\$1/g
or s/(\W)/\\$1/ag
for ASCII characters (with behavior on non-ASCII characters dependent on the unicode_strings feature).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the additional very useful feature that it can be interpolated with \Q
and \E
rather than applied to the whole pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think this is an excellent improvement
Fixes #15221
The documentation and comments was misleading about conflating quoting a metacharacter and escaping it. Since \Q stands for quote, we have to continue to use that terminology. This commit clarifies that the two terms are often equivalent.