in reply to parsing question
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? |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parsing question
by ikegami (Patriarch) on Dec 07, 2006 at 06:54 UTC |