Dr Manhattan has asked for the wisdom of the Perl Monks concerning the following question:
Hi all
I have some data in a hash of hash. I want a function that receive any two strings in my data and return the value.
Here is a example of the data
did la 0.001 did bruja 0.001 did verde 0.001 not Maria 0.001 Mary Maria 0.8 Mary no 0.001 Mary dio 0.001 Mary una 0.001
And here is the code I am currently working on
sub probability { my (%hash, $source, $target) = @_; return $hash{$source}{$target}; } my $test = &probability(%hash, $hash{Mary}, $hash{Mary}{Maria}); print "$test\n";
I expect the output to be 0.8
Thanks in advance for any help
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Send hash of hash arguments to sub
by kcott (Archbishop) on Aug 14, 2013 at 07:47 UTC | |
by tobyink (Canon) on Aug 14, 2013 at 08:58 UTC | |
|
Re: Send hash of hash arguments to sub
by Laurent_R (Canon) on Aug 14, 2013 at 08:26 UTC | |
by Anonymous Monk on Aug 14, 2013 at 09:55 UTC | |
|
Re: Send hash of hash arguments to sub (Dumper reference my %hash = @_ )
by Anonymous Monk on Aug 14, 2013 at 07:28 UTC | |
by Happy-the-monk (Canon) on Aug 14, 2013 at 08:27 UTC | |
by Anonymous Monk on Aug 14, 2013 at 07:35 UTC |