$VAR1 = {
'200534011' => {
'200577234' => {
'CDC Inc.' => {
'2' => 'some text description'
}
}
},
'200110014' => {
'200110325' => {
'CDC Inc.' => {
'1' => 'some text description'
}
}
},
'199989987' => {
'199999991' => {
'CDC Inc.' => {
'4' => 'some text description'
}
}
},
'200323021' => {
'200331234' => {
'ABC Corp.' => {
'3' => 'some text description'
}
}
},
'200212344' => {
'200232399' => {
'CDC Inc.' => {
'3' => 'some text description'
}
}
},
'200210014' => {
'200210105' => {
'XYZ Ltd.' => {
'1' => 'some text description'
},
'ABC Corp.' => {
'1' => 'some text description'
}
}
},
'200211011' => {
'200212053' => {
'XYZ Ltd.' => {
'2' => 'some text description'
},
'ABC Corp.' => {
'2' => 'some text description'
}
}
}
};
####
C:\test>226719
200110100,some text here,etc matches with:
CDC Inc. 1 -some text description
200918943,some text here,etc matches with:
200211015,some text here,etc matches with:
XYZ Ltd. 2 -some text description
ABC Corp. 2 -some text description
199212395,some text here,etc matches with:
200110100,some text here,etc matches with:
CDC Inc. 1 -some text description
200210100,some text here,etc matches with:
XYZ Ltd. 1 -some text description
ABC Corp. 1 -some text description
C:\test>
####
use strict;
use Inline::Files;
use Data::Dumper;
my %corps;
while () {
chomp;
my $name = $_;
;
while() {
chomp;
last if /^\s*$/;
my ($prefix, $start, $end, $text) = /^(\d+)\s+(\d+)\s+(\d+)\s+(.*$)/;
$corps{$start}{$end}{$name}{$prefix} = $text;
}
}
#!print Dumper \%corps;
; #! Skip header
while () {
chomp;
print "\n$_ matches with:";
my ($id, @rest) = /(\d+),(.*$)/;
for my $start ( grep{ $_ <= $id } keys %corps ) {
for my $end ( grep{ $_ >= $id } keys %{$corps{$start}} ) {
for my $name (keys %{$corps{$start}{$end}} ) {
for my $prefix (keys %{$corps{$start}{$end}{$name}} ) {
print "\t$name $prefix -", $corps{$start}{$end}{$name}{$prefix};
}
}
}
}
}
__END__