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

Re: Negated Smart Match

Thread Previous
From:
Ron Blaschke
Date:
January 3, 2008 11:43
Subject:
Re: Negated Smart Match
Message ID:
477D3AD2.2050904@rblasch.org
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 !~~.

Thanks,
Ron

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About