my %hash = (Mary => { Maria => 0.8}, other_keys => "other_values"); sub probability (\%$$) { my ($hash_ref, $source, $target) = @_; return $hash_ref->{$source}{$target}; } my $test = probability(%hash, "Mary", "Maria"); print "$test\n";