use strict; use warnings; use diagnostics; sub switch { no warnings 'exiting'; while (@_) { my ($case, $action) = splice @_,0,2; return $action->($case) if $_ ~~ $case; } } #no warnings 'exiting'; switch [1,2,3] => sub { print "bla" ; next}, 3 => sub { print "bla2" } for (3); #### Exiting subroutine via next at d:/Users/RolfLangsdorf/pm/switch.pl line 18 (#1) (W exiting) You are exiting a subroutine by unconventional means, such as a goto, or a loop control statement.