in reply to Slice of a hash of hashes
This seems to do the job:
#!/usr/bin/perl -w use strict; my @header = ('h1','h2','h3'); # I already know the headings my %values; # make a hash of hashes to remember the values while (<DATA>) { chomp; my @columns = split /\|/; my $unique = $columns[1]; # h2 is the unique identifier @{$values{$unique}}{@header} = @columns; } __END__ val1|one|1 val2|two|2 val3|three|3
I assume that the @values was a typo and have changed it to @columns.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|