use feature "switch"; foreach $a (1..2) { for ($a) { when (1) {print "1\n"; last;} when (2) {print "2\n"; last;} } }