$ipaddr = "192.168.8.205"; @ip = split /\./,$ipaddr; # Split on 2nd . $iprefix =$ip[0] . "." . $ip[1]; print($iprefix);