delimited database perl count

Posted on 2005-05-12
Last Modified: 2010-04-17
Here is what I have:

text delimited data base (sample):
00017|JC||Wed May 11 13:30:35 2005
00013|SD||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

Not sure where to begin.....
Question by:precision
    LVL 1

    Accepted Solution

    #!/usr/bin/perl -w

    open( HND, "./delimited.txt") || die "Cant' Open file : $!";
    @arr = <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";
    LVL 1

    Expert Comment

    you can comment
    $ua->proxy('http', "");

    if you dont' have any proxy in between like:
    #   $ua->proxy('http', "");

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Suggested Solutions

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now