in reply to Re^3: problem unless I use ".="
in thread problem unless I use ".="
From perlop (under Assignment Operators):
Assignment operators work as in C. That is, $a += 2; is equivalent to $a = $a + 2; although without duplicating any side effects that dereferencing the lvalue might trigger
It's that last part, about avoiding dereferencing side effects, that comes into play here.
When you do:
$baseball{yankees} = $baseball{yankees} . $baseball{mets};
you are incurring a side effect of dereferencing $baseball{yankees}, namely testing for definedness, which you won't incur when you use the assignment operator:
$baseball{yankees} .= $baseball{mets}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: problem unless I use ".="
by demerphq (Chancellor) on May 14, 2007 at 08:50 UTC |