in reply to Is this a reasonable data structure?
my @array = (%hash1, %hash2);What you end up with is merely a list of the key/value pairs from %hash1 and %hash2, not an array of hashes.
I really have no idea how you were going to name your hashes like that, so I guessed. Note that you might have to fix the $key definition so that two "B.Smith" people don't collide.use warnings; use strict; my @template; my %data; while (<>) { chomp; my @line = split(/\|/, $_); if (!@template) { @template = @line; } else { my $key = lc($line[2]."_".substr($line[1],0,1)); @{$data{$key}}{@template} = @line; } } use Data::Dumper; print Dumper(\%data);
|
|---|