http://qs1969.pair.com?node_id=502309


in reply to Re^2: "last expression" quiz
in thread "last expression" quiz

As the node you’re replying to already says: check Re^8: Unhappy returns for code.

$ perl -v

This is perl, v5.8.7 built for i486-linux

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^4: "last expression" quiz
by robin (Chaplain) on Oct 23, 2005 at 15:14 UTC
    There is a bug in your code. You've missed out the ->() in the last two cases, so it's printing the sub rather than the result of calling the sub.

      Gack. Thanks for the catch. That was stupid. Fixed, node has been updated.

      The new behaviour is a tad more consistent, but still not consistent with the documentation. What gets returned is the last expression from the body of the do, while the last one evaluated is clearly the while/until condition. (Arguably, the real behaviour is more useful than the strictly doc-adherent one would be.)

      Makeshifts last the longest.