in reply to problem with $ARG
open DNS, "ping -l o -n 1 $host >nil|"||die;
Beware of the precedence of the operators.
Better (iirc):
open( DNS, "ping -l o -n 1 $host >nil|" ) || die $!; # or open DNS, "ping -l o -n 1 $host >nil|" or die $!;
Update:
And I wonder, why you redirect STDOUT of the ping to "nil" and want to parse the STDOUT via Pipe into your Perl program?
Please redirect the output to the file and parse that file afterwards, or redirect the output via Pipe to the Perl program and parse it directly.
open my $pipe, '-|', "ping -l o -n 1 $host" or die $!;
|
|---|