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__