Perl loop break FAQ: How do I break out of a Perl loop?
Problem: You're writing some Perl loop code (for, foreach, or while), and you have a condition where you need to break out of your loop early, and you quickly find out that Perl doesn't have a 'break' operator.
The Perl "break" statement
In many programming languages you use the break operator to break out of a loop like this, but in Perl you use the last operator to break out of a loop, like this: