Threads, Need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthikeyanck
    New Member
    • Oct 2007
    • 23

    Threads, Need help

    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);
    }
    Last edited by NeoPa; Jul 16 '08, 04:04 PM. Reason: Please use the [CODE] tags provided
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Although I am experiencing some issues in adding the code tags to your posting, you really need to use them when adding code to your posts.

    Regards,

    Jeff

    Comment

    Working...