I stored the ranges in an array. If the number of the ranges was large, I'd probably sort them and use binary search to locate the matching one(s).
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
open my $F2, '<', 'file2' or die $!;
my @ranges;
while (<$F2>) {
chomp;
my ($version, $from, $to) = (split /,/)[ 1, 2, 3 ];
push @ranges, [ $from, $to, $version ];
}
open my $F1, '<', 'file1' or die $!;
while (<$F1>) {
chomp;
my $n = substr $_, 11, 9;
my $printed;
for my $r (@ranges) {
if ($r->[0] <= $n && $n <= $r->[1]) {
say "$_,$r->[2]";
$printed = 1;
}
}
say "$_, no match" unless $printed;
}