I am not sure what I need nor how to do it (even after reading through the past discussions). It's all very confusing to me. Let me explain my scenario:
I want to parse through my downloaded bank file (a CSV file and I already figured out how to parse it correctly). I have figured out how to read through each line and separate the debits and credits into various variables such as:
Payments (to me):
Shopify
Etsy
PayPal
Misc
And the same with debits:
Supplies
Shipping
Ads
Online
The issue that I am running into is that I need to split all of this off on an per month basis. My logical mind is telling me to use an @array where $array1 is January, $array2 is February, etc... for each month. (Yes, I am skipping $array[0], just to keep it simple) I could add a hash to the array to corraliate for the month using the key names above. I want to add those values on a dymanic basis as I reiterate through the CSV file. Hopefully, I explained that correctly.
My issue is that I do not know how to reference, for example, the Paypal payment to me for, say, March. and add these totals on an ongoing basis? For example
CSV LINES:
Debit,03/06/2024,Paypal paymemnt, 25.25,debit_card
Debit,03/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
#/usr/bin/perl # use strict; use warnings; use Text::CSV; my @chaseArray; my $chaseCSV = Text::CSV->new ({ binary => 1 }); open my $inFile, '<', "chase.csv" or die $!; my @chaseList; my ($cCosts, $cShip, $cGrovery, $cSocial, $cMonthly, $cMisc, $cShopify +, $cEtsy, $cPaypal, $cVenmo, $csMisc, $cTotal) = 0; while (my $row = $chaseCSV->getline ($inFile)) { @chaseList = @$row; my $month = substr ($chaseList[1], 0, ); if ( $chaseList[2] =~ /.*Shopify.*/ ) { my $temp = $chaseList[3] + %@chaseArray[$month]{Shopify}; # @%chaseArray[$month]{Shopify} += $chaseList[3]; %@chaseArray[$month]{Shopify} = $temp; } } print Dumper \@chaseArray;
I keep getting these errors and I am not sure how to fix it. Any help would be greatly apprecaited.
Note:
Once I get the shopify payments adding correctly, I'll put some elsif statements in there for the rest of the items on my list.
In reply to Hash of Arrays? OR Array of Hashes by fritz1968
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |