Well, I'm not sure on the specifics of what your data looks like, but something like this ought to work:
my $currentRegion = '';
my %regions = ();
while (<FILE>) {
chomp;
/REGION (\d+) (.+)/ and do {
$currentRegion = $1;
$regions{$currentRegion}{Name} = $2;
next;
};
/REGION TOTAL (.+)/ and do {
$regions{$currentRegion}{Total} = $1;
$currentRegion = '';
next;
};
do {
push @{$regions{$currentRegion}{Data}}, $_ if $currentRegion n
+e '';
next;
};
}
You now have a hash of the regions. you can then just call each region that belongs to each person like this:
# steve's regions (some added guessed region numbers for demonstration
+):
foreach my $region ( @regions{ '7A', '8A', '9A' } ) {
#do stuff to each $region that belongs to steve...
}