rational_icthus has asked for the wisdom of the Perl Monks concerning the following question:
The '$file->field(...)' line allows me to dynamically add columns to the report based on existing data. I can't hard code the new column definitions, as this code needs to be somewhat abstract. For that reason, I'm using an anonymous sub to define the value of the field. As the file processor runs, each line will add a column to the report by running that sub, pulling values from that report line. I'd like the '$row' variable to be a hash reference filled with key/value pairs from the current line. I'd like it to be autopopulated in the sub, much like sort {$a <=> $b} @list autopopulates the '$a' and '$b' in the code block there. Is there a way to do this? I've super searched on '$a $b', etc., but too many results are kicking out since those variables are often used as temp variables, etc. Any help would be appreciated. Thanks.# Handles initial parse (gets field # names from first line of 'file.out' my $file = ParseFile('file.out'); # Specifies fields on which to subtotal $file->keys = qw( Cust_Grp Order_Date Item Name ); # Adds a field $file->field('Line_Total', sub { $row->{Unit_Price}*$row->{Qty} }); ... # Process file $file->process();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need an $a and $b as in perl's sort routine
by demerphq (Chancellor) on Jan 10, 2006 at 23:22 UTC | |
by rational_icthus (Sexton) on Jan 10, 2006 at 23:57 UTC | |
by demerphq (Chancellor) on Jan 11, 2006 at 00:53 UTC | |
by duelafn (Parson) on Jan 11, 2006 at 14:54 UTC | |
by demerphq (Chancellor) on Jan 11, 2006 at 16:12 UTC | |
|
Re: Need an $a and $b as in perl's sort routine
by ysth (Canon) on Jan 10, 2006 at 23:20 UTC | |
|
Re: Need an $a and $b as in perl's sort routine
by simonm (Vicar) on Jan 11, 2006 at 00:57 UTC |