use IO::Socket;
for($i=20; $i<300; $i++){ 
  $yhendus = IO::Socket::INET->new(
     Proto     => "tcp",
     PeerAddr  => "tera.hk.tpu.ee",
     PeerPort  => "$i",  	
  );
print $i,"\n";
  if($yhendus){
   print $yhendus "kala\n";
    while($rida=<$yhendus>){
      print "Port $i avatud\n";
      $yhendus->close;      
#print $yhendus "quit\n";	      
      }	  
}
}
