in reply to Re: at continue, last
in thread at continue, last

$loop is used in the conditional, so if I decremented it first, I'd have to add one to it everywhere it is being used.

Replies are listed 'Best First'.
Re^3: at continue, last
by LanX (Saint) on Jun 06, 2014 at 17:55 UTC
    > $loop is used in the conditional, so if I decremented it first,...

    Unclear.

    None of your examples have $loop in the conditional and I suggested decrementing it after not before !

    Please explain what's different here

    if ( $condition1 ) { ... unless( $condition2 ) { ... } --$loop; # common exit point }

    Cheers Rolf

    (addicted to the Perl Programming Language)

      Sorry, my reply was clearer in my head then in my written words

      I meant to write that if I decremented it as the first statement in the if clause, I'd have to increment later on.

      The point of the examples wasn't the decrement, but to examine the ways of finding a single path to cleanup code from a conditional. In particular, I'm trying to avoid the nested if/else/unless clauses.

        > In particular, I'm trying to avoid the nested if/else/unless clauses.

        As I already explained you have always the same exit point. where the decrement can safely happen.

        May it be last or goto LABEL , you have plenty of possibilities to reach it, w/o nesting if clauses.

        Cheers Rolf

        (addicted to the Perl Programming Language)

Re^3: at continue, last
by djerius (Beadle) on Jun 06, 2014 at 17:44 UTC
    Whoops. Forgot to log in. The above comment is mine.