sub test { my ( $s ) = @_; if ($s == 3) { no warnings 'exiting'; # suppress the warning for this lexical scope only. next; } else { print $s . "\n"; } } #### use strict; use warnings; my @stuff = 1..5; for my $s (@stuff) { next if is_bad_stuff($s); my $formatted = format_stuff($s); print "$formatted: passed\n"; } sub is_bad_stuff { my ( $s ) = @_; return $s == 3; } sub format_stuff { my ( $s ) = @_; $s = '' return "Formatted $s"; }