use strict; my $ip = '1.2.3.4'; my @ip = split(/\./,$ip); $ip[3]++; print join('.',@ip) , "\n";