use IO::Handle;
use Socket;
use threads;
use IO::Socket::INET;
open(pctxt,'./pc.txt')||die "error open $!";
while($read_data = <pctxt>)
{
chomp;
$read_data=~s/\s//g;
$read_data=~s/" "//g;
thread($read_data);
}
close(pctxt);
sub thread
{
my $net = shift;
my @ip = (1..255);
my $port = 12345;
my $thr0 = threads->new(\\&scan, "$net@ip[0..63]", $port);
my $thr1 = threads->new(\\&scan, "$net@ip[64..127]", $port);
my $thr2 = threads->new(\\&scan, "$net@ip[128..191]", $port);
my $thr3 = threads->new(\\&scan, "$net@ip[192..254]", $port);
$thr0->join();
$thr1->join();
$thr2->join();
$thr3->join();
}
sub scan
{
my (@hosts, $port) = @_;
foreach my $host (@hosts)
{
my $socket = new IO::Socket::INET
(
PeerHost => $host,
PeerPort => $port,
Proto => "tcp",
);
if($socket)
{
print $port,"is open!\\n";
$socket->close();
}
}
}
####################################################
After running,prompt Errors as following;
thread failed to start: Not a CODE reference at pcmnt.pl line 28.
thread failed to start: Not a CODE reference at pcmnt.pl line 29.
thread failed to start: Not a CODE reference at pcmnt.pl line 30.
thread failed to start: Not a CODE reference at pcmnt.pl line 31
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.