I 've got this script here and struggling to apply threads to the "ping" part of the program, Any help much appreciated.
Code:
use Net::Ping;
use Getopt::Std;
sub usage
{
print "pingscan -f <Input file> -o <Output file>";
exit 0;
}
my %options;
getopts('f:o:',\%options) || die usage();
usage() if!($options{'f'});
usage() if!($options{'o'});
$p = Net::Ping->new("icmp");
if($options{'f'}){
$ipfile = $options{'f'};
}
if($options{'o'}){
$opfile = $options{'o'};
}
chomp($ipfile);
open I,"<$ipfile" || die ("cannot open file");
@host = <I>;
chomp($opfile);
open P,">>$opfile" || die ("cannot create output file");
foreach (@host){
print P $_ if $p->ping($_, 2);
}
Comment