in reply to Pinging multiple hosts
#!/usr/bin/perl use Net::Ping; my ( @ips, @up ); $" = "\n"; while(<>) { chomp; push @ips, $_ if /^(\d{1,3}\.){3}\d{1,3}$/; } print @ips; my $p = Net::Ping->new( "syn", 5 ); $p->{port_num} = 7; $p->ping($_) for (@ips); while ( my ( $host, $rtt, $ip ) = $p->ack ) { push @up, $ip; } print @up;
|
|---|