Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

List counting in perl

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
Europa MacDonald
Asked:
Europa MacDonald
1 Solution
 
ozoCommented:
/^101,[^,]*,[^,]*,(\d+)/
0
 
Europa MacDonaldChief slayer of dragonsAuthor Commented:
great thankyou
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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