Re: copying and s/// (was Re: Overlapping RFCs 135 138 164)

[email protected] (Brad Hughes)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected]>
Nathan Wiger wrote:
[...]
> RFC 164 v2 has a new syntax that lets you do the above or, if you want:
> 
>    $this = s/foo/bar/, $that;
>    @these = s/foo/bar/, @those;
> 
> Consistent with split, join, splice, etc, etc.

I often use the comma operator like this

  s/foo/bar/, $n++ if $x;

If "s" is now a 2 parameter operator like split and
join, how is it parenthesized?

  s(/foo/bar/, $_), $n++ if $x;

in which case the parser/lexer may be looking for a subst of the
form s()(), or

  (s/foo/bar/), $n++ if $x;

which seems like "s" will be evaluated in list context, and
therefore will use @_ instead of $_.  My assumption here is that

  $x = s/foo/bar/;

defaults to

  $x = s/foo/bar/, $_;

and

  @x = s/foo/bar/;

defaults to

  @x = s/foo/bar/, @_;

although I may have missed something.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.