Solved

List counting in perl

Posted on 2013-11-21
2
187 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using Perl to parse rows 7 93
how to exit a  for loop inside a function with return value in bash 5 96
combine multiple lines 2 44
Control Number of Log Files -Perl 7 55
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

12 Experts available now in Live!

Get 1:1 Help Now