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

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

Tony Cook via RT
September 16, 2019 04:56
[perl #134250] /c modified with substitute s///
Message ID:
On Mon, 01 Jul 2019 12:38:24 -0700, wrote:
> This is a bug report for perl from,
> 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.


via perlbug:  queue: perl5 status: new Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About