Test1|Test2|Test3 Foo1|Foo2|Foo3Code
use strict;
my @records;
my @keys = qw(FirstKey SecondKey ThirdKey);
sub getkey()
{
my $ret = shift @keys;
push @keys, $ret;
return $ret;
}
open IN, "<test.txt";
while(<IN>)
{
my %record;
map{$record{getkey()}=$_} split(/\|/) ;
push(@records,\%record);
}
foreach my $rec (@records)
{
my %thing = %{$rec};
foreach my $key (@keys)
{
print "$key: $thing{$key}\n";
}
}
--In reply to Re: split to hash, problem with random keys
by jdklueber
in thread split to hash, problem with random keys
by december
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |