#tested my %dispatch = ( INTEGER => \&checkInteger, DATE => \&checkDate, IPADDRESS => \&checkIpaddress, FOO => \&checkFoo ); my $type = "INTEGER"; my $answer = "44"; die "can't do $type" unless exists $dispatch{$type}; my $convAnswer = $dispatch{$type}->($answer); sub checkInteger { print "int" } sub checkDate { print "date" } sub checkIpaddress { print "ip" } sub checkFoo { print "foo" }