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

Re: Negated Smart Match

Thread Previous | Thread Next
Michael G Schwern
January 3, 2008 02:53
Re: Negated Smart Match
Message ID:
Ron Blaschke wrote:
> Congrats to you all to the recent Perl 5.10 release!  I'm just taking
> some time to explore the new features and I have a quick question.
> The new smart matching operator C<~~> is great, is there a negated
> version of it?  I tried C<!~~> but that doesn't quite work as expected:

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

Treat it like cmp or <=> keeping in mind that ~~ has a higher precedence than
the comparison ops.  So you want either:

	not $value ~~ @array;


	!($value ~~ @array);

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 !~~.

Whip me, beat me, make my code compatible with VMS!

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