Monks:
Trying to modify script to give me a subtotal of column 14 (see below.)
while (<>) {
s/\r?\n$//;
my @c = split /$sep/o;
my $sub_total = 0;
$sub_total += $c[14];
my $key = join $sep, @c[ @col ];
if (not defined $lines{ $key }) {
$lines{ $key } ||= [];
};
push @{ $lines{$key}}, $_
push @{ $totals{$key}}, $sub_total
}
My code is failing with the following:
"my" variable %lines masks earlier declaration in same scope at ./part-v2.pl line 179.
"my" variable $key masks earlier declaration in same statement at ./part-v2.pl line 180.
syntax error at ./part-v2.pl line 176, near "$_
push"
syntax error at ./part-v2.pl line 176, near "}}"
Global symbol "$sub_total" requires explicit package name at ./part-v2.pl line 177.
syntax error at ./part-v2.pl line 191, near "}"
Execution of ./part-v2.pl aborted due to compilation errors.
========================
Any help would be appreciated.