Re: smart match question

2010-11-27 Thread Chap Harrison
> Yes. The smart match operator was commutative only in version 5.10 of perl. > The change was made in the very next release - version 5.10.1. > Just wondering now -- does ... @divisors ~~ 2 ... have any meaning now? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional c

Re: smart match question

2010-11-27 Thread Rob Dixon
On 27/11/2010 18:16, Téssio Fechine wrote: 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

Re: smart match question

2010-11-27 Thread Téssio Fechine
changed. > De: 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 b

Re: smart match question

2010-11-27 Thread magnus
my @divisors = (1, 2); say "It's divisible by 2!" if @divisors ~~ 2; 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

Re: Re: smart match question

2010-11-27 Thread Téssio Fechine
I'm running perl 5.10! -- perl -v This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi -- A think it's no longer true then: "The smart match operator is commutative, which you may remember from high school algebra as the fancy way to say that the order of the operands doesn’t matter.

Re: smart match question

2010-11-27 Thread Chap Harrison
On Nov 27, 2010, at 9:01 AM, Chap Harrison wrote: > On Nov 27, 2010, at 7:45 AM, Téssio Fechine wrote: > >> Why "@divisors ~~ 2" is not true? > > No idea - it seems to work fine for me: > - - - > /Users/chap/private/perl$ cat smart > use 5.010; > use strict; > use warnings; > > my @divisors =

Re: smart match question

2010-11-27 Thread Chap Harrison
On Nov 27, 2010, at 7:45 AM, Téssio Fechine wrote: > -- > tes...@krauzer:~/Perl/Ex/ch15$ cat smart > > use 5.010; > > use strict; > > use warnings; > > > > my @divisors = (1, 2); > > say "It's divisible by 2!" if @divisors ~~ 2; > > tes...@krauzer:~/Perl/Ex/ch15$ perl smart > > tes...@kra

smart match question

2010-11-27 Thread Téssio Fechine
Another day, another problem.. =/ -- tes...@krauzer:~/Perl/Ex/ch15$ cat smart use 5.010; use strict; use warnings; my @divisors = (1, 2); say "It's divisible by 2!" if @divisors ~~ 2; tes...@krauzer:~/Perl/Ex/ch15$ perl smart tes...@krauzer:~/Perl/Ex/ch15$ -- Why "@divisors ~~ 2" is no