sub probability { my (%hash, $source, $target) = @_; return $hash{$source}{$target}; } my $test = &probability(%hash, $hash{Mary}, $hash{Mary}{Maria}); print "$test\n";