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