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

Re: Negated Smart Match

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
January 3, 2008 02:53
Subject:
Re: Negated Smart Match
Message ID:
477CBE7E.40704@pobox.com
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;

or

	!($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


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