> Here's the same thing but "Perl Best Practice" ified a bit:
> 
> #!/usr/bin/perl
> 
> use strict;
> use wanrings;
> use Net::Ping;
> 
> die 'Please give me a filename as my argument!' if !defined $ARGV[0];
> open(my $ipfile_fh, '<', $ARGV[0]) || die "Could not open $ARGV[0]:
$!";
> 
> my $icmp = Net::Ping->new('icmp');
> 
> while(<$ipfile_fh>) {
>      chomp $host;

I've only peeked inside my newly purchased 'Perl Best Practices' book,
but I'm willing to bet that there is a section on declaring/scoping
variables ;).

$host wasn't previously declared in any context so the 'strict' pragma
is gonna complain.  For every instance of $host in _this_ example,
replace it with Perl's favorite: $_.

ry

> 
>      if( $icmp->ping($host, 2) ) {
>          print "$host is alive! weeeee\n";
>      }
>      else {
>          print "$host is dead. boooo\n";
>      }
> 
>      sleep 1;
> }
> 
> $icmp->close();
> close $ipfile_fh;
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to