in reply to Re^3: Hash w/ multiple values + merging
in thread Hash w/ multiple values + merging
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Hash w/ multiple values + merging
by sophix (Sexton) on Feb 08, 2010 at 01:08 UTC | |
by GrandFather (Saint) on Feb 08, 2010 at 01:17 UTC | |
by sophix (Sexton) on Feb 08, 2010 at 01:40 UTC | |
by sophix (Sexton) on Feb 08, 2010 at 02:52 UTC | |
|
Re^5: Hash w/ multiple values + merging
by sophix (Sexton) on Feb 08, 2010 at 00:41 UTC |