develooper Front page | perl.perl5.porters | Postings from September 2016

Re: [perl #129283] Compile-time check for $1, $2 om RHS of s///operator

Thread Previous | Thread Next
From:
Abigail
Date:
September 16, 2016 21:33
Subject:
Re: [perl #129283] Compile-time check for $1, $2 om RHS of s///operator
Message ID:
20160916213635.GA8770@almanda.fritz.box
On Fri, Sep 16, 2016 at 04:15:13AM -0700, Ed Avis wrote:
> # New Ticket Created by  "Ed Avis" 
> # Please include the string:  [perl #129283]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=129283 >
> 
> 
> 
> This is a bug report for perl from eda@waniasset.com,
> generated with the help of perlbug 1.40 running under perl 5.22.2.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Currently this gives a run-time warning, but no compile-time error:
> 
>     use 5.022;
>     $_ = 'abc';
>     s/(a)/x$1$2/;
>     say;
> 
> If the regexp on the LHS of s/// is known at compile time, then the
> number of capturing groups it contains is known.  Under 'use strict',
> a mention in the RHS of a capture variable which doesn't have a
> corresponding capturing group (like $2 in the above example)
> should give a compile-time error.
> 


"use strict" never promotes a 'Use of uninitialized value' to an
error. I don't think perl being consistent when it comes to s///
is a bug.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About