in reply to Problem in a Loop

If you want to loop over the keys of the hashes, you have to say so:

foreach my $key (keys %$observation){ foreach my $key (keys %$observation){

Replies are listed 'Best First'.
Re^2: Problem in a Loop
by madM (Beadle) on Sep 19, 2013 at 13:22 UTC
    now it works but i have another question .. do you know why when i print data Dumper i donīt get anything?
    my $freqocurrence={}; sub freq_oc{ foreach my $key (keys %$observation){ $total10 += $observation->{$key}; } foreach my $key (keys %$observation){ $freqocurrence->{$key} = $observation->{$key}/$total10; print "Frequency of ocurrence: Aminoacid $key-> $freqocurrence +->{$key}\n"; } } print Dumper $freqocurrence;

      I can only guess that your script misses the following three lines near the top:

      use strict; use warnings; use Data::Dumper;
Re^2: Problem in a Loop
by madM (Beadle) on Sep 19, 2013 at 13:12 UTC
    thanks! i completely forgott it! :D