Europa MacDonald
asked on
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 ?
#!/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 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER