in reply to Re^5: out of memory problem
in thread out of memory problem

Hi GrandFather, Thank you very much for your code.
Now I want to increase the weight of transitive relations from ++$mappings{$A}{$_} to $mappings{$A}{$_} = $mappings{$A}{$_} +5.
But can you please tell me how to print just the values that are greater than 1?
I tried the following:
for my $key (keys %mappings) { if($mappings{$key}{$_} > 1 ) print "$key - $mappings{$key}{$_} -> $_\n" for keys %{$mapping +s{$key}} ; }
But there is this error:
Use of uninitialized value in numeric gt (>) at test.pl line 33, <$tes +tdataset> line 7.
Thanks

Replies are listed 'Best First'.
Re^7: out of memory problem
by GrandFather (Saint) on Mar 26, 2006 at 05:18 UTC

    Changing the print loop to:

    for my $key (keys %mappings) { for (keys %{$mappings{$key}}) { next if $mappings{$key}{$_} < 2; print "$key - $mappings{$key}{$_} -> $_\n" ; } }

    Prints:

    lung cancer - 2 -> some cancer cancer - 4 -> foot cancer

    for the code I posted. Note that in the original code for keys %{$mappings{$key}} is a statement modifier and the if statement that you inserted is outside the inner loop so $_ is bogus. The code needed to be changed around into a full for loop so the condition can be checked inside the inner loop.


    DWIM is Perl's answer to Gödel