in reply to replacing the last portions of an octet
Here's another option:
use Modern::Perl; my $IPs = '192.168.1.1-192.168.1.254'; $IPs =~ s/(.+\.)(\d+)(\s*-\s*.+\.)(\d+)/$1 . ($2 - 1) . $3 . ($4 + 1)/ +e; say $IPs;
Output:
192.168.1.0-192.168.1.255
|
|---|