develooper Front page | perl.perl5.porters | Postings from May 2012

Re: Bug? (was Re: proposal: functional C<if>...)

Thread Previous | Thread Next
From:
Uri Guttman
Date:
May 5, 2012 00:50
Subject:
Re: Bug? (was Re: proposal: functional C<if>...)
Message ID:
4FA4DBC8.5000505@stemsystems.com
On 05/05/2012 03:27 AM, Linda W wrote:
> Linda W wrote:
>> Why should this yield an error:
>>
>> @_ ? #if (@_) {
>> ($M, $tM)=(shift, 100*$H+$M)
>> : #}else{
>> ($H, $M) = (int $H/100, $tM % 60);
>> #}
>> Assignment to both a list and a scalar at /tmp/pp.pl line 12, near ");"
>>
>> Where's the assignment to a scalar?
> ---
> Seems like this might also be a problem in 5.14... as it doesn't work
> there either.
>
> Is there some other interpretation that I'm missing?
>

a classic bug in your code. = binds tighter than ?:. the rule is never 
to use ?: for side effects like =. it should be used for its result 
expression only. you broke the rule.

uri

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