You have not declared the variable, $_second_octet_num variable. I don't know how your program is generating 192.168.1.1 to 192.168.1.254 without that.
Here I am giving the code for generating a IP address from 192.168.1.1 to 192.168.254.254. You can adjust the code according to your situation.
#!/usr/bin/perl use strict; use warnings; my $first_octet_num = "1"; my $ip_address; foreach (1..254) { foreach (1..255) { if ($_ <= 254) { $ip_address = join ('.', 192,168,$first_octet_num,$_); print "$ip_address\n"; } else { $first_octet_num++; } } }
One more information for you, IP address start with 192, it's not class B. It's class C. Reference here.
In reply to Re: Generation of sequential IP addresses for Class B network
by irah
in thread Generation of sequential IP addresses for Class B network
by perlpal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |