in reply to how to initiate an array or an hash with name from captured string in pattern matching?
A hash of hashes is probably what you should be using. Maybe something like:
open (my $fd, '<','./dump2.txt') or die "Can't open dump2.txt"; while (<$fd>) { chomp; my @dump = split(/\t/); my $tbl_last = "FIL"; my %data; foreach my $it (@dump) { if ($it =~ m/([A-Z]{3})\.(.+)/) { my $tbl = $1; my ($col, $val) = split('=',$2); # print "$it\t$tbl\t$col\t$val\n"; $data{$tbl}->{$col} = $val; } } print Dumper(\%data);
You can learn more about such data structures by reading perldsc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to initiate an array or an hash with name from captured string in pattern matching?
by hihilo (Initiate) on Nov 14, 2010 at 17:22 UTC |