in reply to next within one subroutine that looks to another subroutine

Keywords (not functions... thanks dragonchild)</s> like next and last and used in the context of loops. next goes to the next iteration of the loop, last leaves the loop.
foreach(1,2,3) { next if ($_ == 2); print "next: $_\n"; } foreach(1,2,3) { last if ($_ == 2); print "last: $_\n"; } __RESULTS__ next: 1 next: 3 last: 1

Rich36
There's more than one way to screw it up...

Replies are listed 'Best First'.
Re: Re: next within one subroutine that looks to another subroutine
by dragonchild (Archbishop) on Feb 13, 2002 at 19:44 UTC
    <DIRECTED RANT>
    1. next and last are keywords, not functions. You cannot redefine their behavior. If they were functions, you'd be able to do so.
    2. The question was concerning the capabilities of next and last when the scope had changed, especially concerning nested function calls. I would assume that, given the nature of the question, that the questioner knew how to use next and last.
    </DIRECTED RANT>

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.