use strict; my @stuff = (1, 2, 3, 4, 5); foreach my $s (@stuff) { test($s); print "past\n"; } sub test { my ( $s ) = @_; if ($s == 3) { next; #note that this is not within a loop in the #scope of the subroutine } else { print $s . "\n"; } }