On Wed, 23 Feb 2005, TapasranjanMohapatra wrote:

> I have a script as follows
> ----------------------------
> my $host = shift;
> my $count = shift;
> my $result = `ping -c $count $host`;
> if($result =~ m/$count packets transmitted, $count packets received/)
> {
>  $success = 1;
> }
> print "$result\n";
> ----------------------------
 
Is there a reason you're using backticks instead of just doing this all 
in Perl directly?

    <http://search.cpan.org/~bbb/Net-Ping-2.31/lib/Net/Ping.pm>

This sidesteps having to make a regex to parse the results, which will 
work inconsistently (that is, not at all) with other versions of `ping`. 

This approach should be more flexible in general; the documentation at 
the URL above should give you the tools you need to do what you want in 
a reliable, portable way.


-- 
Chris Devers

-- 
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