http://qs321.pair.com?node_id=442840


in reply to Re^2: Stupid mistakes I repeatedly make
in thread Stupid mistakes I repeatedly make

Just to follow this thread off-topic ... how often does it matter? I can't even think of any time where I cared how many items were replaced with s///. And it's almost never when I don't care about the resultant string. So, yes, I'd agree that PHP's method is as flexible as Perl's, but I would suggest that the s operator is not Huffman-coded properly. The thing that we do most often (care about the resultant string) is the most work. Even if the difference is minor (an extra set of parens), Larry seems to talk a lot about "natural language" for perl 6, and I'd suggest that the current syntax is less natural. If, for example, s/// returned the resultant string in scalar context and the list of substitutions in list context, you could get the number of substitutions with my $num = @{[s/$re/foo/g]}; (although that syntax is probably not so ugly in perl 6 either). Given the rareness of its use (if my experience is any indication, or even in the same ballpark as reality in general), I think this would make more sense.

I seem to recall that perl6 is supposed to solve all of this, so not only is this thread off-topic, but probably moot anyway ;-)