Am 16.09.2016 um 23:36 schrieb Abigail: > 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 > >> >> 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. I agree. It's not that $2 doesn't exist there; it just contains undef. 'strict' seems the wrong place for this check. I would like to see it as a warning, but I don't know how hard it would be to implement (e.g. you'd have to check for embedded regex matches that could reset capture variables). -- Lukas Mai <plokinom@gmail.com>Thread Previous | Thread Next