Assuming the individual numbers are in the range 0 - 255 then you can do this
my $min = canonical('2.0.0.0');
my $max = canonical('3.0.0.0');
my @versions = qw(1.0.0.0 1.1.10.1 3.1 2.0.1 1.9.9.9.9 3.0.0.0.0.0.0.1
+ 2.9 2.0.0.0 2.1.0.0 10.6.1.0);
foreach my $version ( @versions) {
my $canonical = canonical($version);
print "$version\n" if ( $min le $canonical && $canonical le $max )
+;
}
sub canonical {
return pack 'C*', split /\./, $_[0];
}
__END__
2.0.1
2.9
2.0.0.0
2.1.0.0
Update: removed assumption that the version strings need to have the same number of numbers.