my %hash = ( foo => sub {uc shift}, ); print $hash{foo}->("hello\n");