# We can use below code to generate IP range
use warnings;
use strict;
my $startIp = $ARGV[0];
my $endIp = $ARGV[1];
sub range {
my (@ip,@newIp,$i,$newIp,$j,$k,$l,$fh);
my ($j1,$k1,$l1);
open($fh,">","ip.txt") or die "could not open the file $!";
@ip = split(/\./,$startIp);
for($i=$ip[0];$i<=255;$i++) {
for($j=$ip[1];$j<=255;$j++) {
$ip[1]=0 if($j == 255);
for($k=$ip[2];$k<=255;$k++) {
$ip[2]=0 if($k == 255);
for($l=$ip[3];$l<=255;$l++) {
$ip[3]=0 if($l == 255);
@newIp = $newIp = join('.',$i,$j,$k,$l);
print $fh "$newIp \n";
exit if ($newIp eq $endIp);
}
}
}
}
}
range ($startIp, $endIp);