Uri Guttman wrote:
>>>>>> "SB" == Steve Bertrand <st...@ibctech.ca> writes:
> 
>   SB>     $user_ref->{$username}{payment} += $payment ||= $payment;
>   SB>     $user_ref->{$username}{amount}  += $amount  ||= $amount;
> 
> assuming no entries in payment or amount, you don't need the ||= at
> all. += will work on an undef (or non-existing hash) value and coerce it
> to 0 and then add the number. it will not trigger warnings as this is a
> useful case of ignoring undef values. .= (append string) also doesn't
> trigger warnings for the same reason.
> 
> perl -lwe 'my %x; print( $x{y} += 3 )'
> 3
> 
> perl -lwe 'my $x ; print( $x .= "cd" )'
> cd
> 
> perl does all sorts of little things like that. read more about
> autovivication in my article:
> 
>       http://sysarch.com/Perl/autoviv.txt

I read this twice this afternoon.

Just now I'm reviewing code that was causing me subtle grief a few weeks
ago that I need to perform a translation from one storage format to another.

I found a line that started like this:

next if ! exists *insert_hash_with_complex_data*

heh.

Between the books, practical playing, and this list, I'm thinking that I
like programming Perl nearly as much as I enjoy engineering the network!

Steve

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to