in reply to How to exit out of a sub routine
How does someone exit from a sub routine without exitting altogether?
Using return.
sub doit { ... if (nothing_else_to_do) { return; } ... }
If you want to exit with a catchable error, you can use die or croak.
sub doit { ... if (did_not_provide_gizmo) { die("Gizmo required"); } ... }
I know with arrays you can do LAST to stop the iterations.
last (and next and redo) affect loops, not arrays. Specifically,
while (and until) loops:
while (...) { ... last; ... }
C-style for loops, foreach loops and counting loops:
for (...) { ... last; ... }
Bare loops:
{ ... last; ... }
|
|---|