in reply to Pop quiz: find the bug

Update: black on black is a good one. So here comes:

An assignment returns the variable being assigned to as an lvalue, which the following && evaluates to its value. Therefor, ($something += $amt) will return 0 if that is $something's new value, causing the following && to fall through and miss the last. As a result, at least one too many variables get updated within the same switch statement - potentially even all of them.

As far as the distributive referentiation is concerned, check the Camel book, chapter 8, under "Creating references" in subsection "More tricks with references". (I hope I have the names right - what I have is the German translation.) It's also documented in perlref, under "Making References", at the end of point 2.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re(2): Pop quiz: find the bug
by FoxtrotUniform (Prior) on Jul 04, 2002 at 02:28 UTC

    That's Chapter 8 (p. 246) of the English second edition Camel book, for those of you with obsolete references Perl 5 as a target platform.

    --
    The hell with paco, vote for Erudil!
    :wq