in reply to how can I print my hash values once?
You're iterating over the values, then proceed to use it as the key. I suspect you want
foreach my $geneid ( sort { $geneids{$a} <=> $geneids{$b} } keys %geneids ) { print OUT "Chromosome $geneid has $geneids{$geneid} genes\n"; }
Also switched from cmp to <=> so that 10 comes after 2.
Oh! And you want to move the foreach outside of the while loop.
Update: Added last paragraph.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how can I print my hash values once?
by lomSpace (Scribe) on Mar 10, 2011 at 14:29 UTC | |
by ikegami (Patriarch) on Mar 10, 2011 at 19:55 UTC | |
by lomSpace (Scribe) on Mar 11, 2011 at 15:17 UTC | |
by ikegami (Patriarch) on Mar 11, 2011 at 21:50 UTC | |
by umasuresh (Hermit) on Mar 10, 2011 at 14:59 UTC |