in reply to Friday Code Quiz

Invisible(ish) answer ahead, select with your mouse or have a look at the source to view it:

$i contains 1, because, due to precedence, the expression is treated as (($i = 1),(2)) which is legal and this expression itself returns 2 in scalar context (the last element), and it returns (1, 2) otherwise.

Am I right? :-)

-- TMTOWTDI

Replies are listed 'Best First'.
Re: Re: Friday Code Quiz
by davorg (Chancellor) on Sep 21, 2001 at 15:39 UTC

    Spot on. Well done.

    It's the relative precedence of '=' and ',' that confuses most people.

    Update: Slight spoiler blackboxed.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."