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

[perl #134250] /c modified with substitute s///

From:
Tony Cook via RT
Date:
September 16, 2019 04:56
Subject:
[perl #134250] /c modified with substitute s///
Message ID:
rt-4.0.24-25042-1568609788-1994.134250-15-0@perl.org
On Mon, 01 Jul 2019 12:38:24 -0700, jim.avera@gmail.com wrote:
> 
> This is a bug report for perl from jim.avera@gmail.com,
> generated with the help of perlbug 1.40 running under perl 5.26.2.
> 
> 
> -----------------------------------------------------------------
> 'man perlop' indicates that the /c modifier may be used with the
> substitution operator:
> 
> "s/PATTERN/REPLACEMENT/msixpodualngcer"
>         Searches a string for a pattern, and if found, replaces that
> pattern
>         with the replacement...
> 
> but it does not seem to be implemented.
> Any use of /c with s/// produces
> 
> "Use of /c modifier is meaningless in s///"
> 
> Suggest fixing/clarifing the docs (or better, make it work i.e. leave
> pos() set to the character following the last match with /c is used).

Making /c behave like for s/// would be the reverse of the meaning of /c from m//.

Currently m/.../c prevents pos() being reset when the regexp doesn't match, but that's the case with s/// anyway (with or without the /g).

Changing s///c to modify pos() might break existing code that was written without warnings, so we'd need to go through a deprecation cycle to remove it (which adds a default on warning rather than the default off warning you get now.)

A non-deprecation documentation patch is attached.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134250



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