I need to generate a list of IP-addresses (IPv4) in Perl. I have start and end addresses, for example 1.1.1.1 and 1.10.20.30. How can I print all the addresses inbetween?
It's all in how you code it. This is the fastest way I know.
my $start = 0x010101; # 1.1.1 my $end = 0x0a141e; # 10.20.30 for my $ip ( $start..$end ) { my @ip = ( $ip >> 16 & 0xff , $ip >> 8 & 0xff , $ip & 0xff ); print join( '.', 1, @ip ), "\n"; }