develooper Front page | perl.perl5.porters | Postings from January 2008

Re: Negated Smart Match

Thread Previous
Ron Blaschke
January 3, 2008 11:43
Re: Negated Smart Match
Message ID:
Michael G Schwern wrote:
> Ron Blaschke wrote:

> I don't think there is a !~~ operator in Perl 5 and, in desperation, it
> interpreted it as !~ ~ (negated regex match with bitwise negation).

Yes, actually I was a bit surprised how hard Perl tries to make sense of it.

> Treat it like cmp or <=> keeping in mind that ~~ has a higher precedence than
> the comparison ops.  So you want either:
> 	not $value ~~ @array;
> or
> 	!($value ~~ @array);

Sounds good, thanks.

> This does leave open the issue of whether there should be a negative smart
> match operator.  Seems like there should be, given the trap that !$a ~~ $b
> forms.  Perl 6 has one and it is !~~.

I agree.  And it would provide symmetry with comparison and regex
matching.  On the other hand, not sure if this new operator would hurt
anyone, given the current interpretation of !~~.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About