Perl Telnet Scanner, quite noisy though..

Code:
#!/usr/bin/perl

# WARNING - THIS SCRIPT IS PROOF OF CONCEPT AND NOT FOR MALICIOUS USE #
# THIS SCRIPT WILL LEAVE LOG ENTRIES AND MAKE NOISE - SO BE WARNED #
use IO::Socket;
########################### IP GENERATOR ########################
sub ipgen(){
my $range1 = 223;                        #avoid experimental and multicast
my $range2 = 254;                
$oct1 = int(rand($range1)) + 1;                    #generate random octects
$oct2 = int(rand($range2)) + 1;
$oct3 = int(rand($range2)) + 1;
$oct4 = int(rand($range2)) + 1;

if($oct1 == 127 || $oct1 == 172 || $oct1 == 192 || $oct1 == 10){#if gets rid of loopbacks and private ips
$ip = &ipgen();                            #if local or private call again
}else{
$ip = "$oct1.$oct2.$oct3.$oct4";                # otherwise allocate the ip to return
}
return $ip;                            #return to caller        
}
#################################################################
############################## MAIN #############################
print "########################################\n";
print "#---------Random Telnet Scanner--------#\n";
print "#-----------Written by 50LaR15---------#\n";
print "########################################\n";
while(1==1){                            # keeps code running indefinatly
$target = &ipgen();                        # get random ip to scan
print "*??* SCANNING: $target \n";                    # output
my $sock = new IO::Socket::INET (                # try to create socket to chose random address
                 PeerAddr => $target,
                 PeerPort => '23',        # change this number to change ports you want to detect
                 Proto => 'tcp',
                 Timeout => '2',         # you can get away with a timeout of 1 second but i have 2 to be safe
                 );
if($sock){                            # if socket opened (port open)
print "*!!* SUCCESS-: $target \n";                # print to screen
open(DAT, ">>telnet.txt") || die("Cannot Open Output File");     # open results file
print DAT "SUCCESS: $target \n";                # append findings to end of file
close(DAT);                            # close the file
}
close($sock);                            # close the socket
}################################################################