use Test::More tests => 2; my %nested = ( first => { one => 'two' }, second => { three => 'four' } ); sub get_element { my ($level_one, $level_two, %nested) = @_; return $nested{ $level_one }{ $level_two }; } is( get_element( 'first', 'one', %nested ), 'two', 'first element access' ); is( get_element( 'second', 'three', %nested ), 'four', 'second element access' );