in reply to Counting hash values
output:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash = map {split /\s+/} <DATA>; my %new_hash; for my $key (keys %hash){ if ($key =~ /213119_at/){ $new_hash{$hash{$key}}++; } } print Dumper \%new_hash; __DATA__ Affy:HG_U133A:213119_at:74:303; ENSG00000123643 Affy:HG_U133A:213119_at:542:439; ENSG00000123643 Affy:HG_U133A:213119_at:658:369; ENSG00000123643 Affy:HG_U133A:213119_at:199:255; ENSG00000123643 Affy:HG_U133A:213119_at:436:453; ENSG00000123643 Affy:HG_U133A:213119_at:324:381; ENSG00000458158 Affy:HG_U133A:213119_at:584:557; ENSG00000123643 Affy:HG_U133A:213119_at:234:507; ENSG00000123643 Affy:HG_U133A:213119_at:482:429; ENSG00000123643 Affy:HG_U133A:213119_at:608:451; ENSG00000458158 Affy:HG_U133A:213119_at:356:297; ENSG00000123643
note: there are 9 :-)---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl $VAR1 = { 'ENSG00000123643' => 9, 'ENSG00000458158' => 2 }; > Terminated with exit code 0.
|
|---|