Perl Programming/Keywords/last

The last keyword
last is the same as break in C-like languages and is used to make the program immediately exit the current loop. Withou LABEL, the innermost loop is assumed. From Perl 5.18.0 onwards, it is possible to compute the LABEL during runtime by passing an EXPRESSION.

If a loop has a last command, the continue block is skipped.

<tt>last</tt> cannot be used to exit a block that returns a value (as it is the case with <tt>do {}</tt>, <tt>eval {}</tt>, or {}<tt>sub {}</tt>. It should not be used to exit a <tt>grep</tt> or <tt>map</tt> operation.