To avoid using "real" files for demonstration purposes I used Perl's facility for using a string as a file by passing a reference to the string into the open. To open a real file instead you should:
open my $in, '<', $fileName or die "Unable to open $filename: $!";
Please follow my advice and use strictures (use strict; use warnings; - see The strictures, according to Seuss), the three parameter form of open and lexical file handles (the 'my $in' bit in my sample code). These tips will save you time in the future!
If you open an output file ($out) before the loop in my sample code you can change the print to:
printf $out $format, $key, @{$data{$key}}{@columnNames};
to print to the output file instead of STDOUT. Note that for testing and sample code using STDOUT is often much more convenient!
In reply to Re^4: Hash w/ multiple values + merging
by GrandFather
in thread Hash w/ multiple values + merging
by sophix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |