On Fri, Jun 17, 2011 at 3:49 PM, Florian Pflug <fgp@phlo.org> wrote:
>> The regex is always to the right of the operator.
>
> Which is something you have to remember... It's not in any
> way deducible from "foo ~ bar" alone.
Except that it's always been this way, going back to perl4 or tcl or
their predecessors. The regexp binding operator always has the regexp
on the right.
>>> How is that worse than the situation with "=~" and "~="?
>>
>> With =~ it is to the right, with ~= it is to the left.
>
> It's always where the tilde is. Yeah, you have to remember that.
And when you get it wrong it will fail silently. No errors, just wrong results.
While I've never accidentally written /foo/ =~ $_ in perl I have
*frequently* forgotten whether the operator is ~= or =~. Actually I
forget that pretty much every time I start writing some perl. I just
put whichever comes first and if I get an error I reverse it.
I can see the temptation to make it symmetric but it's going to cause
an awful lot of confusion.
Perhaps we could name the operators ~~= and =~~ and then have a =~
short-cut for compatibility? (and ~ too I guess?)
--
greg