• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

delimited database perl count

Here is what I have:

text delimited data base (sample):
00017|JC|68.192.000.000|Wed May 11 13:30:35 2005
00013|SD|68.196.000.000|Wed May 11 13:31:49 2005

The first data piece in each row (i.e., column A, 00017 & 00013) are various tags that I want to count and display the results, as a summary.  The data base may be 400 rows, and about 40 variations of column a.

I would like results to say something like:

00017 total count 35
00013 total count 19
etc...

Not sure where to begin.....
0
precision
Asked:
precision
  • 2
1 Solution
 
srikpenCommented:
#!/usr/bin/perl -w


open( HND, "./delimited.txt") || die "Cant' Open file : $!";
@arr = <HND>;
close(HND);


for ( @arr ) {
          @line = split/\|/;
        if( $hash{$line[0]} ) { $hash{$line[0]} = ++$hash{$line[0]}; }
        else { $hash{$line[0]} = 1; }
}

for ( keys %hash ) {
        print $_   .  " total count $hash{$_}\n";
}
0
 
srikpenCommented:
you can comment
$ua->proxy('http', "http://www.company.com:80");

if you dont' have any proxy in between like:
#   $ua->proxy('http', "http://www.company.com:80");
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now