siffland has asked for the wisdom of the Perl Monks concerning the following question:
I have the following Perl script and it works just how I want it to. The only problem I have have is when executed each line of the output is tabbed (staggard) instead of left justified. This is the first time i have ever attempted to use the curses module. If there is another module that will work better let me know.
#!/usr/bin/perl use Curses; use Net::Ping; @host_array = qw(fee fie foo quan); initscr(); noecho(); cbreak(); nodelay(1); while(1) { clear (); refresh(); # High precision syntax (requires Time::HiRes) foreach $host (@host_array) { $p = Net::Ping->new(); $p->hires(); ($ret, $duration, $ip) = $p->ping($host, 5.5); printf("$host [ip: $ip] is down\n") unless $p->ping($host, 2); printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n", + 1000 * $duration) if $ret; $p->close(); } sleep 2; }
thanks, Sean
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Curses formatting
by Fletch (Bishop) on Jan 21, 2010 at 22:24 UTC | |
|
Re: Curses formatting
by Khen1950fx (Canon) on Jan 21, 2010 at 22:54 UTC |