use strict;
use warnings;
my $cmd = "/usr/sbin/ntpq -p";
my $offset = (split(/\s+/, (grep(/^\*/, `$cmd`))[0]))[8];
print "$offset\n";
####
use strict;
use warnings;
my $cmd = "/usr/sbin/ntpq -p";
my @ntpout = `$cmd`;
my $current_time_source = (grep(/^\*/, @ntpout))[0];
my $offset = (split(/\s+/, $current_time_source))[8];
print "$offset\n";
##
##
use strict;
use warnings;
my $cmd = "/usr/sbin/ntpq -p";
my @ntpout = `$cmd`;
die "$cmd failed with: $^E, $?" unless(@ntpout);
my $current_time_source = (grep(/^\*/, @ntpout))[0];
die "Not synchronized" unless($current_time_source);
my $offset = (split(/\s+/, $current_time_source))[8];
die "$current_time_source: No offset" unless(defined($offset));
print "$offset\n";