in reply to processing key value pairs of a hash
use strict; use warnings; use Data::Dumper; my %clone_hash; while (<DATA>) { my ($key, $value) = split; my $grade = ($value =~ /^pass[1-3]$/) ? 'good' : 'bad'; $clone_hash{$key}{$grade}++; } print Dumper(\%clone_hash); __DATA__ Eif2b2 fail Eif2b2 pass5 Eif2b2 fail Eif2b2 pass2 Eif2b2 fail Eif2b2 pass4 Eif2b2 fail 49334 fail 49334 fail 49334 pass1 49334 fail 49334 pass4 Oxct1 pass4 Oxct1 fail Oxct1 pass4 Oxct1 fail
which prints out (unsorted):
$VAR1 = { 'Eif2b2' => { 'good' => 1, 'bad' => 6 }, '49334' => { 'good' => 1, 'bad' => 4 }, 'Oxct1' => { 'bad' => 4 } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: processing key value pairs of a hash
by lomSpace (Scribe) on Apr 15, 2009 at 15:34 UTC | |
by lomSpace (Scribe) on Apr 15, 2009 at 16:20 UTC | |
|
Re^2: processing key value pairs of a hash
by lomSpace (Scribe) on Apr 15, 2009 at 14:16 UTC | |
by toolic (Bishop) on Apr 15, 2009 at 16:34 UTC | |
by lomSpace (Scribe) on Apr 15, 2009 at 16:45 UTC | |
by lomSpace (Scribe) on Apr 15, 2009 at 18:42 UTC | |
by toolic (Bishop) on Apr 15, 2009 at 19:27 UTC | |
by lomSpace (Scribe) on Apr 16, 2009 at 13:28 UTC |