in reply to return if 0

It has to do with the if condition being a constant. See this old node: Re^3: A cleaner way of scoping variables.

Replies are listed 'Best First'.
Re^2: return if 0
by ikegami (Patriarch) on Jun 23, 2009 at 12:24 UTC

    No, it doesn't.

    #!perl -l sub test_c { $x=2; return 1 if 0; } sub test_v { $x=2; return 1 if $_[0]; } print test_c(); print test_v(0);
    0 0

    If an optimisation changes Perl's behaviour, it would be a bug.