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)