Skip to content

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

Open
wants to merge 2 commits into
base: blead
Choose a base branch
from

Conversation

khwilliamson
Copy link
Contributor

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.

  • This set of changes does not require a perldelta entry.

@khwilliamson khwilliamson force-pushed the escape branch 2 times, most recently from ede7f9d to 8d8d490 Compare May 6, 2025 14:56
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
Copy link
Contributor

@Grinnz Grinnz May 7, 2025

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).

Copy link
Contributor

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.

Copy link
Contributor

@Grinnz Grinnz left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misuse of "quote" in place of "escape" in documentation
4 participants