my %switch = (  "host1.com" => \&DoAction1,  "host2.de"   => \&DoAction1,  "host3.xyz"  => \&DoAction2,  "host4.das"  => \&DoAction3); if (exists $switch{$element} and ref($switch{$element} eq 'CODE') {  $switch->$element->($param1, $param2, $param3, ...) } else {  die "Error: no action for '$element' specified\n"; } sub DoAction1 {  my ($p1, $p2, $p3) = @_;  print "Action1\n"; } sub DoAction2 {  my ($p1, $p2, $p3) = @_;  print "Action2\n"; } sub DoAction3 {  my ($p1, $p2, $p3) = @_;  print "Action3\n"; }