# Counting values in a list 2

I know very little about PERL :(

I have list of millions of rows of data. All data values are separated by a comma

I have to count how many rows contain a specific data value

for example

101,102,143,145,146,149
101,102,143,145,147,148
101,102,143,145,147,149
101,102,143,145,148,149
101,102,143,146,147,148
101,102,143,146,147,149
101,103,143,146,148,149
101,103,143,147,148,149
101,103,144,145,146,147
102,104,144,145,146,148
102,104,144,145,146,149
102,104,144,145,147,148

from that sample list, I have to count how many rows have the value 103 for the second data entry, so for this list the number of rows with 103 in the second data entry would be 3

Could someone help me with a PERL script that I can run as a .pl file and will

1. open the file  (filename:  master.vim )
2. Count through all the rows and record the number of rows with the value at that data point - in the second column
3. write the recorded number of rows to another file (  count103.txt  )
4. close master.vim and count.txt

###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
``````#!/usr/bin/perl

open FILE, "<master.vim";
my \$count = 0;

while(<FILE>) {
my @columns = split(',');
if(\$columns[1] eq '103') {
\$count++;
}
}
close FILE;

open OUT, ">count.txt";
print OUT "\$count\n";
close OUT;
``````

Experts Exchange Solution brought to you by