foreach $row (@array) { next unless routine($row); # more code here } sub routine { if ($row != '10') { print "stuff"; return 1; } else { return 0; } }