Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: replacing the last portions of an octet

by Kenosis (Priest)
on Sep 18, 2012 at 20:14 UTC ( #994352=note: print w/ replies, xml ) Need Help??


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


Comment on Re: replacing the last portions of an octet
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-02 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls