in reply to Re: Load a file into hash with duplicate keys
in thread Load a file into hash with duplicate keys
I had come across this script in the net, however, it repeats the key in the values.
#!/usr/bin/perl -w use Data::Dumper; my $data = '/Data/Table1.txt'; open INFILE, '<', $data or die "a!\n"; while(<INFILE>) { chomp; my $line = $_; my $key = (split/\t/, $line)[0]; push @{ $hash{$key} }, $line; } print Dumper(\%hash);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Load a file into hash with duplicate keys
by umasuresh (Hermit) on Nov 02, 2010 at 20:46 UTC | |
by sophix (Sexton) on Nov 02, 2010 at 20:54 UTC | |
by Anonymous Monk on Nov 02, 2010 at 21:02 UTC | |
by Anonymous Monk on Nov 02, 2010 at 21:06 UTC | |
by sophix (Sexton) on Nov 02, 2010 at 21:12 UTC | |
by Anonymous Monk on Nov 02, 2010 at 21:14 UTC | |
|