my %functions = ( 'this' => sub { ... }, 'that' => \&do_something, ); my %attrs = (...); my $key = 'this'; $functions{$this}->(\%attrs);