#!/usr/bin/perl # http://perlmonks.org/?node_id=1206349 use strict; use warnings; print "Enter the IP address\n"; my $tunip = ; chomp ($tunip); print $tunip =~ s/\d+$/ ($& - 1 ^ 1) + 1 /er, "\n";