Solved

List counting in perl

Posted on 2013-11-21
2
186 Views
Last Modified: 2013-11-21
This code counts the number of rows with each new value in column three of my data

#!/usr/bin/perl
use strict;
use warnings;
open M,"<master.vim" or die "master.vim $!";
my %c;

 /^101,(\d+)/ &&  $c{$1}++ while <M>;

close M;
open C,">count.txt" or die "count.txt $!";
print C "$c{$_}\n" for sort{$c{$b}<=>$c{$a}}keys %c;
close C;

Could the code be altered to do the same thing, but for the fourth column ?
0
Comment
Question by:MichaelGlancy
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39666034
/^101,[^,]*,[^,]*,(\d+)/
0
 

Author Closing Comment

by:MichaelGlancy
ID: 39666100
great thankyou
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

707 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

10 Experts available now in Live!

Get 1:1 Help Now