I have a file of check book data. Here's a sample line:
"Lunch Place", 1/22/2010, -4.110000, "Lunch", "", , 0
I want to run through the file, add up all the entries that say lunch and then see how much I spend a year on lunch.
# this is the format of the lines # "Description", "Date", "Amount", "Category", "Memo", "Check Number", + "Reconciled" my $file = "checkdata.csv"; open( F, "$file" ); my @lines = <F>; my $sum = 0; foreach my $line ( @lines ) { chomp( $line ); my @data = split( ",", $line ); my $v = $data[2]; my$vplus = $v + 1; # I tried doing this to take care of trailing zeros, leading space + and minus. my $data[2] =~ /\s*(-?\d*\.\d*)0000/; my $v2 = $1; print " $v plus 1 is $vplus\n"; print " $v2 is regexed\n"; $sum = $sum + $data[2]; } print $sum;
Here is a sample output line. -27.000000 plus 1 is 1 is regexed I am SO CLUELESS. I've used a lot of perl in the past and I can't for the life of me figure out whats going on and I'm going INSANE. Please, someone explain this to my addled brain before I use up all my brain matter on a brick wall.
In reply to Why won't it please be a number? by chuckhazard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |