in reply to Net::Ping and STDOUT
Or else you may simply have a problem with buffering. Are you trying to read from the file before the writing has terminated? Try adding e.g. $|++ at the top of your script.
Update: OTOH, it doesn't have anything to do with your problem, but generally Perl-style for loops are preferrable over C-style ones. Your script may be rewritten as (untested):
Please note that I also made a few minor, "cosmetic", changes. E.g. I turned a print into a warn. This may not be what you want, but is often appropriate in similar situations.#!/usr/bin/perl -l use strict; use warnings; use Net::Ping; my @net=map "192.168.$_", qw/97 100 102 104 105 32 33 34/; my $p=Net::Ping->new or die "Can't create ping object: $!\n"; for my $net (@net) { for (16..250) { my $host="$net.$_"; warn "$host not responding!\n" and next if !$p->ping($host); print $host; } } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Net::Ping and STDOUT
by yam (Novice) on Aug 04, 2005 at 16:12 UTC | |
by blazar (Canon) on Aug 04, 2005 at 16:24 UTC | |
by yam (Novice) on Aug 04, 2005 at 17:18 UTC | |
|
Re^2: Net::Ping and STDOUT
by yam (Novice) on Aug 04, 2005 at 17:25 UTC | |
by blazar (Canon) on Aug 04, 2005 at 17:45 UTC |