An example using the IP decimal octet regex from Regexp::Common's friend Regexp::Common::net:
>perl -wMstrict -le "use Regexp::Common qw(net); ;; my $s = shift; print qq{'$s'}; ;; $s =~ s{ \b ($RE{net}{IPv4}) - ($RE{net}{IPv4}) \b } { add_oct($1, -1) . '-' . add_oct($2, +1) }xmse; print qq{'$s'}; ;; sub add_oct { (my $ip = $_[0]) =~ s{ (\d+) \z }{ ($1 + $_[1]) & 0xff }xmse; return $ip; } " "192.168.1.1-192.168.1.255" '192.168.1.1-192.168.1.255' '192.168.1.0-192.168.1.0'
In reply to Re: replacing the last portions of an octet
by AnomalousMonk
in thread replacing the last portions of an octet
by diamondsandperls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |