Smart match operator was commutative the first time it was introduced.
So "@divisors ~~ 2" would search for 2 in the list of divisors..
For any reason smart match is not commutative anymore, so the right syntax now 
is "2 ~~ @divisors"..

The problem is that the syntax has changed.


> De: mag...@trapd00r.se <mag...@trapd00r.se>
> Assunto: Re: smart match question
> Para: beginners@perl.org
> Data: Sábado, 27 de Novembro de 2010, 12:31
>
> How do you think that would work?
> From perldoc perlop:
>
> >>        Binary "~~" does a
> smart match between its arguments. Smart
> >>        matching is described
> in "Smart matching in detail" in perlsyn.
>
>
> my @divisors = (1 .. 6);
> for my $i(@divisors) {
>   if(i % 2 == 0) {
>     print "$i is divisible by 2\n";
>   }
> }
>
> if(3 ~~ @divisors) {
>   print "value 3 exists in \...@divisors\n";
> }
>




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to