#!/usr/bin/perl use strict; use warnings; my %test = ( code => sub { my $input = shift; if ($input eq 'h') { return 'hallo'; } }, ); $test{code1}= sub { my $input=shift; if ($input eq 's') { return 'sonne'; } }; my $foo = $test{code}->('h'); print "$foo\n"; # hallo erwartet $foo = $test{code1}->('s'); print "$foo\n"; # sonne erwartet