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

Re: Using smart matching to find whether an array contains a string

Thread Previous | Thread Next
From:
Ed Avis
Date:
January 26, 2011 08:19
Subject:
Re: Using smart matching to find whether an array contains a string
Message ID:
loom.20110126T171733-695@post.gmane.org
Abigail <abigail <at> abigail.be> writes:

>>     % perl -E '@a = ("1"); say "1 x" ~~ @a'
>> 
>>     % perl -E '@a = (1); say "1 x" ~~ @a'
>>     1

>>This is the only place in everyday Perl programming where the difference is
>>noticeable.
>
>False, unfortunally.
>
>    $ perl -wE 'say 10 | 33'
>    43

Ah - I do not use the | operator in everyday programming (in fact, I don't think
I have ever used it) so I didn't think of this case.

>And it can even be more subtle:
>
>    $ perl -E '$a = $b = "abc100"; 0 + $b; say $a; say $b;
>                             $a ++; $b ++; say $a; say $b'

That is a nasty one.  Surely the expression 0 + $b should not mutate the value
of $b.  I'm surprised this is not considered a bug?

-- 
Ed Avis <eda@waniasset.com>


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