my %switch = ( 1 => \&function1, 2 => \&function2, 4 => \&function3, default => \&irgendwas, ); my $key = 1; if ($key and exists $switch{$key}) { $switch{$key}->($params); # erst jetzt wird es ausgefuehrt } else { # default, wenn noetig $switch{'default'}->($params); }