> Just to extend this idea, at least for the exercise of it, consider:
>
> match; # all defaults (pattern is /\w+/?)
> match /pat/; # match $_
> match /pat/, $str; # match $str
> match /pat/, @strs; # match any of @strs
>
> subst; # like s///, pretty useless :-)
> subst /pat/new/; # sub on $_
> subst /pat/new/, $str; # sub on $str
> subst /pat/new/, @strs; # return array of modified strings
For the takes-an-array variants of match and subst, what becomes of
back-references? Does
subst PAT, LIST
modify LIST in-place, or return the result of modification? What does
match PAT, LIST
return at all, and what of multiple back-references in PAT?
> # These are pretty cool...
> foreach (@old) { @new = subst /hello/X/gi, @old;
> s/hello/X/gi;
> push @new, $_;
> }
>
> foreach (@str) { print "Got it" if match /\w+/, @str;
> print "Got it" if (/\w+/);
> }
This implies that the subst keyword would *both* modify LIST in-place and
return a complete copy of the list as a return-value. Is this correct?
Additionally, the match example above is not identical on each side-- the
Perl 5 version would print "Got it" for *every* matching element of @str,
whereas the Perl 6 version would print it just once. While you could change
the Perl 5 example to fit (by adding "last"), I just don't know that the
blind application of a regex to a list has a place here.
Randy
--
-------------------------------------------------------------------------------
Randy J. Ray | Programming is a Dark Art [...] The programmer is fighting
[EMAIL PROTECTED] | against the two most destructive forces in the universe:
415-777-9810 x246 | entropy and human stupidity. --Dr. Damian Conway