in reply to Using HoH data in formats
The more and more i think about your problem (and i still don't know exactly what you are trying to do), the more and more i feel you should be using DBD::CSV. Why? Because your data files are CSV and you are reporting on them, and when it comes to reporting, SQL is quite nice.
The following code was based off of BrowserUk's data and output.use strict; use warnings; use DBI; use File::Basename; my @stuff; my $file = 'sfoct01.txt'; my $table = (fileparse($file,'.txt'))[0]; my $dbh = DBI->connect( "DBI:CSV:f_dir=.;csv_eol=\n;csv_sep_char=,;", {RaiseError=>1}, ); $dbh->{csv_tables}->{$table} = { file => $file, col_names => [qw(account amount)], }; my $sth = $dbh->prepare(" SELECT account,amount FROM $table ORDER BY account "); $sth->execute; while (my ($account,$amount) = $sth->fetchrow_array()) { @stuff = ($account, $amount, 10, 10 - $amount); write; } format STDOUT_TOP = +-----------------------------------------------------------------+ | Monthly Recap | |----------------------------+----------+-----------+-------------+ |Account | Prior | Current | Difference | |----------------------------+----------+-----------+-------------+ . format STDOUT = |@<<<<<<<<<<<<<<<<<<<<<<<<<<<|@#####.## | @#####.## | @#####.## | @stuff |----------------------------+----------+-----------+-------------+ . __END__ yields: +-----------------------------------------------------------------+ | Monthly Recap | |----------------------------+----------+-----------+-------------+ |Account | Prior | Current | Difference | |----------------------------+----------+-----------+-------------+ |Bam bam | 5.00 | 10.00 | 5.00 | |----------------------------+----------+-----------+-------------+ |Betty | 300.00 | 10.00 | -290.00 | |----------------------------+----------+-----------+-------------+ |Wilma | 200.00 | 10.00 | -190.00 | |----------------------------+----------+-----------+-------------+ |barney | 30.00 | 10.00 | -20.00 | |----------------------------+----------+-----------+-------------+ |fred | 10.00 | 10.00 | 0.00 | |----------------------------+----------+-----------+-------------+
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|