#!/usr/bin/perl use warnings; use IO::Socket; # scan($port, $end_port, $target); scan(1, 2500, '192.168.0.1'); sub scan { my ($from, $to, $where) = @_; print "Scanning $where | from port $from to $to\n\n"; for my $p ($from .. $to) { print "Port $p is open\n" if IO::Socket::INET->new( PeerAddr => $where, PeerPort => $p, Proto => 'tcp', Timeout => 1, ); } print "Port scan complete\n\n"; }