in reply to Re: part - split up files according to column value
in thread part - split up files according to column value
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: part - split up files according to column value
by aaron_baugher (Curate) on Jul 10, 2012 at 22:39 UTC |