Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Count ID values

by murugaperumal (Sexton)
on Mar 20, 2010 at 06:53 UTC ( #829770=note: print w/ replies, xml ) Need Help??


in reply to Re: Count ID values
in thread Count ID values

use strict; use warnings; use Data::Dumper; open FH,"<file" or die "can't Open $!\n"; my $line; my %hash; while($line=<FH>) { my($value,$value2)=split(' ',$line); $hash{$value}+=$value2; } foreach my $key (keys%hash) { print "$key => $hash{$key}\n" }


Comment on Re^2: Count ID values
Download Code
Re^3: Count ID values
by ungalnanban (Pilgrim) on Mar 20, 2010 at 06:54 UTC
    See the following Code:
    open(FH,"file"); foreach $line (<FH>) { if($line=~/^Db/) ### Get only the ID lines. { ($id,$count)=split(' ',$line); $count{$id}+=$count; } } print "ID\t\tCount\n"; foreach $key (keys%count) { print "$key\t$count{$key}\n" }
    --$ugum@r--

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://829770]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-05 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls