Skip Menu |

This queue is for tickets about the Perl-Critic-Pulp CPAN distribution.

Report information
The Basics
Id: 103302
Status: open
Priority: 0/
Queue: Perl-Critic-Pulp

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: PerlMinimumVersionAndWhy : Document workarounds for qr{}m

As the ways of avoiding the qr{}m issue is not obvious, this blob aught to have some documentation explaining workarounds.

Some of this is required due to the over-application of https://metacpan.org/pod/Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching wherein people add /m , and then not until later does somebody realise the compatibility problems that implies.
 

1. If you need to match start and end of a *string*, use \A and \z respectively. They behave the same regardless of the /m modifier.

2. If you need the possibly-multiple-matching start and end of _LINES_ ( The condition usually indicated by /m + ^$ ), then a suggested workaround is to rewrite it in terms of (?m:  ... )

https://rt.perl.org/Public/Bug/Display.html?id=7781

However, as to whether or not this has side effects, I am unable to confirm that at this time, only that some clarity needs to be found at some stage for backcompat reasons.

 

Subject: Re: [rt.cpan.org #103302] PerlMinimumVersionAndWhy : Document workarounds for qr{}m
Date: Mon, 13 Apr 2015 12:50:12 +1000
To: "Kent Fredric via RT" <bug-Perl-Critic-Pulp [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"Kent Fredric via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > As the ways of avoiding the qr{}m issue is not obvious, this blob aught to have > some documentation explaining workarounds.
Is there somewhere good I can cross-reference which describes the issues and maybe suggested action? I agree unless you know what this "propagates properly" refers to that it's obscure as it stands.

On 2015-04-13 14:54:14, user42_kevin@yahoo.com.au wrote:
>
> Is there somewhere good I can cross-reference which describes the
> issues and maybe suggested action?
>
> I agree unless you know what this "propagates properly" refers to that
> it's obscure as it stands.

I was unable to find a good source, as it is, the qr//m bug is essentially undocumented, and the only place that passes for documentation is the note in perl5101delta that says "Oh, we missed this remark from perl5100delta, but this was fixed in 5.10.0 ..."

Which is a bit daft _now_.

 

Either way, its something I'm still learning via discovery. Via discovery I also found that in perlre, whenever it talks about "newline", it is in fact talking about "\n", and it is system agnostic in interpretation ( that is, $ will only match \n, not \r\n on windows ).

 

The only distinctions between a literal \n and $ are:

 

-  $ can match end of string as well as end of line
-  $ is a zero-width positive lookahead, in that it matches *before* the \n, not after it.

- ^ can match the start of the string as well as *after* the \n
- ^ is also zero-width, but lookbehind.

Which means you can represent a multiline  ^ using:

 (?<=\A|\n)

And a multiline $ using:

  (?=\z|\n)

 

And this article says similarly: http://stackoverflow.com/a/11232261/15614