Another way to do it:
#!/usr/bin/perl use strict; use warnings; open my $cmd, '-|', '/usr/sbin/ntpq', '-p' or die "Cannot open pipe fr +om ntpq because: $!"; while ( <$cmd> ) { my $offset = ( split )[ 8 ]; print "$offset\n" if /^\*/; } close $cmd or warn $! ? "Error closing ntpq pipe: $!" : "Exit status $? from ntpq";
In reply to Re: using Backtick inside perl gives different output
by jwkrahn
in thread using Backtick inside perl gives different output
by kaka_2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |