2013/8/15 Uri Guttman <u...@stemsystems.com>:
> On 08/14/2013 04:22 PM, Jim Gibson wrote:
>>
>>
>> On Aug 14, 2013, at 12:30 PM, Alexey Mishustin wrote:
>>
>>> Testing a value and assigning it - I have never done this at the same
>>> time...
>>
>>
>>
>> Doing both in while statements is very common:
>>
>>    while( my $line = <$fh> ) {
>>      ...
>>    }
>>
>> Try to write that loop with two separate statements, one an
>> assignment
>
> and the other an if statement, and you may see the advantage of the
> currently-allowed syntax.
>>
>>
>> The general policy is that assignment statements return a value that
>
> may be further used or tested.
>>
>>
>
> i have a common idiom when dealing with a value in a hash:
>
>         if( my $foo = $ref->{foo} ) {
>
>                 do stuff with $foo
>         }
>

OK, you have got me convinced. It's useful.

I'm sorry only that there is no built-in option with which one could
enable/disable easily assignments inside `if'. (E.g., like re 'eval'/
no re 'eval'). It would "provide choices"...

-- 
Regards,
Alex

-- 
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