I'm new to perl programming. I've a csv file as below.
20100221, abc_1, 200
20100221, abc_4, 350
20100221, opq_3, 200
20100221, abc_5, 220
20100221, xyz_1, 500
20100221, abc_2, 500
20100221, abc_3, 100
20100221, xyz_2, 700
20100221, opq_2, 350
20100221, xyz_3, 100
20100221, opq_1, 230
I'm trying to get output as below, by adding matching values:
Output:
20100221, abc, 1370
20100221, xyz, 1300
20100221, opq, 780
I've started coding as below, but not able to continue due to lack of experience.
use strict;
use warnings;
my $inputfilename = $ARGV[0]; ### CSV file name. ###
open( my $in_fh, "<", $inputfilename ) or die "Can't open $inputfilename : $!";
while (my $line = <$in_fh>) {
chomp($line);
my @columns = split(',', $line, 2);
Could any of you help me to accomplish my requirement?
Thanks and Regards / Lokesha