use strict; use warnings; use Data::Dumper; my @fields = qw/num name G A plus S PIM MIN MAJ ten GM GR MT PPG SH +G GWG OTG UAG ENG FG/; my $pattern = "A3 A21 A4 A5 A5 A5 A5 A5 A5 A5 A5 A5 A5 A5 A5 + A5 A5 A5 A5 A5"; my @data; while (my $line = <DATA>) { chomp($line); next if ($line !~ /^\d+ /); my %hash; @hash{@fields} = unpack($pattern,$line); # unpack the data accordi +ng to the pattern push(@data,\%hash); } print Dumper \@data; ## UPDATE: Reformated code
| XP matters not. Look at me. Judge me by my XP, do you? |
In reply to Re: parsing question
by grep
in thread parsing question
by smist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |