in reply to Re^3: Summing Up Array Elements By Group
in thread Summing Up Array Elements By Group

$b++ needs to create a new anonymous scalar because the result is different than the $b.

++$b just returns a pointer to $b.

$ perl -le'my $b = 4; $r = \( $b++ ); $$r = 20; print $b' 5 $ perl -le'my $b = 4; $r = \( ++$b ); $$r = 20; print $b' 20

Replies are listed 'Best First'.
Re^5: Summing Up Array Elements By Group
by hbm (Hermit) on Jan 21, 2009 at 19:06 UTC
    Nice! One point for your original and another for gwadej's explanation.