in reply to Oddness with lvalue and if/else blocks

Not what you asked, but the trinary op is an lvalue, making this construction easy and correct:

sub foo :lvalue { $_[0] ? $bar : $baz }
I think the problem with yours is that the last evaluated statement in the sub is the whole if..else block.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Oddness with lvalue and if/else blocks
by Aristotle (Chancellor) on Sep 09, 2004 at 07:47 UTC

    Note that there is subtlety involved. According to -MO=Deparse,-x7 the compiler does turn his if/else construct into something pretty close to

    $_[0] ? do { $bar } : do { $baz }

    where the do-blocks are B::Deparse's way of explaining the world more so than they really exist.

    That's obviously not ultimately the same as an explicit ternary, though.

    Makeshifts last the longest.