#!/usr/bin/perl use strict; use warnings; use Text::CSV_XS; my $chaseCSV = 'Text::CSV_XS'->new ({ binary => 1 }); my $inFile = *DATA; my @chaseArray; while (my $row = $chaseCSV->getline($inFile)) { my @chaseList = @$row; my $month = substr $chaseList[1], 0, 2; if ($chaseList[2] =~ /(Paypal|Etsy)/) { my $company = $1; my $temp = $chaseList[3] + ($chaseArray[$month]{$company} // 0); $chaseArray[$month]{$company} = $temp; } } use Data::Dumper; print Dumper \@chaseArray; __DATA__ Debit,01/06/2024,Paypal paymemnt, 25.25,debit_card Debit,01/09/2024,Paypal paymemnt, 10.13,debit_card Debit,03/15/2024,Etsy paymemnt, 52.23,debit_card Debit,03/22/2024,Paypal paymemnt, 16.52,debit_card #### $VAR1 = [ undef, { 'Paypal' => '35.38' }, undef, { 'Paypal' => '16.52', 'Etsy' => '52.23' } ];