in reply to Suggestions & Improvements on a portscanner using IO::Socket

I think your script is great, so forgive me if this seems
a bit nit-picky :)

I think you could improve your script like so ...
change
my $sock; my @openports = (); my $i = -1; print "Scanning $host for open ports.....\n\n"; foreach my $cport (@ports) { $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $cport, Proto => $proto); if($sock) { $i++; $openports[$i] = $cport; } }
... to ...
my $sock; my @openports = (); print "Scanning $host for open ports.....\n\n"; foreach my $cport (@ports) { $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $cport, Proto => $proto); if($sock) { push ( @openports, $cport); } }
... that $i = -1 thing bugs me :/
But good example of a port scanner!