Skip Menu |

This queue is for tickets about the Net-Ping CPAN distribution.

Report information
The Basics
Id: 3321
Status: rejected
Priority: 0/
Queue: Net-Ping

People
Owner: Nobody in particular
Requestors: marachia [...] fr.ibm.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Pb with Net::Ping and print statement
Hello, First : This is perl, v5.6.0 built for i386-linux Package Net-Ping-2.31.tar.gz OPerating system : Linux pcmngt.pssc_network 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown Second : I have a script perl which must increment a variable and print this variable on screen. when I use the Net::Ping package to use that, there is nothing on screen and variable is printed only at the end of the scan. I think a sample will be more explicit. Here is a code derivated from the sample found on man page for Net::Ping : *********************************************************** #!/usr/bin/perl -w use Net::Ping ; use strict ; my $host ; my @host_array = qw (192.168.1.10 192.168.1.11 192.168.1.12 192.168.1.13) ; my $p = Net::Ping->new("icmp"); $p->bind("192.168.1.48"); # Specify source interface of pings foreach $host (@host_array) { print "$host is "; print "NOT " unless $p->ping($host, 1); print "reachable.\t"; # <===CHANGE IS HERE sleep(1); } $p->close(); exit ; ****************************************************************** From the sample provided, I just changed from "\n" to "\t" which is TAB. In this case, assuming that the first 2 hosts are not reachable (.10 and .11), the scrip prints on screen only after the end of the script. If I use "\n" instead of "\t", the scrip prints all sentences one after the other using the right way. I don't see any entry about this problem anywhere. I am not a Perl guru and I don't think to be able to look at the Net::Ping package to try to solve this pb. It will be so great if you have the time to look at this problem and tell me how to solve it. Many thanks in advace for your help. Pascal MARACHIAN
From: Igor Rumiha
[guest - Fri Aug 22 12:04:50 2003]: Show quoted text
> From the sample provided, I just changed from "\n" to "\t" which is > TAB. In this case, assuming that the first 2 hosts are not > reachable (.10 and .11), the scrip prints on screen only after the > end of the script. > > If I use "\n" instead of "\t", the scrip prints all sentences one > after the other using the right way.
This is not a Net-Ping problem. Perl print statement prints into an output buffer, which does not get flushed at least until you print a "\n". Try running this: perl -e 'for ($i = 0; $i < 300; $i++){print "test\t"; sleep 1;}' You will see that nothing gets printed for a long time. Now run this: perl -e '$| = 1; for ($i = 0; $i < 300; $i++){print "test\t"; sleep 1;}' Notice the "$| = 1". It turns on autoflushing. Read man perlvar for more information.