Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Increment of ip address

by cool_jr256 (Acolyte)
on Jun 16, 2005 at 16:02 UTC ( [id://467334]=note: print w/replies, xml ) Need Help??


in reply to Increment of ip address

'1.2.3.5' is being treated as a string (because of the '.'). You can split up the IP into an array, hence being able to increment any of the ip numbers:
$ip="1.2.3.4"; @ipnum=split(/./,$ip); $ipnum[$#ipnum]++; # this increments the last digit.. # then $ip=join(".",@ipnum); # result is '1.2.3.5';

Replies are listed 'Best First'.
Re^2: Increment of ip address
by davidrw (Prior) on Jun 16, 2005 at 17:07 UTC
    Make sure that you split on /\./ and not just 'dot', which is any character. Also, if you increment 192.168.255.255 with that method you're not going to get what you want ... (see other responses for modules to do it for you)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-26 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found