in reply to Atomic Time and Date

here's a version that doesn't rely on parsing the output of the scalar version of localtime:
#!/usr/bin/perl -w use strict; use Net::Time qw(inet_time); my $date_and_time = inet_time('cesium.clock.org', 'tcp'); my ($sec, $min, $hour, $day, $month, $year) = (localtime($date_and_time))[0..5]; my $new_date = sprintf "%02d/%02d/%04d", $month + 1, $day, $year + 190 +0; my $new_time = sprintf "%02d:%02d:%02d", $hour, $min, $sec; system('time', $new_time) or die "Couldn't set time: $!"; system('date', $new_date) or die "Couldn't set date: $!";

Replies are listed 'Best First'.
RE: RE: Atomic Time and Date
by providencia (Pilgrim) on Jun 05, 2000 at 19:48 UTC
    I keep getting:
    C:\WINDOWS\COMMAND.COM /c perl time-date-other.pl
    Couldn't set time: No such file or directory at time-date-other.pl line 14.
    Hit any key to close this window...

    I changed the last two lines to:
    system("time $new_time"); system("date $new_date");

    and it works. It seems to be the:
    or die "Couldn't set time: $!"; or die "Couldn't set date: $!";

    It doesn't work with those.
    I don't have a clue as to why. ??!!??
    I like it though.
      no, i think it's the change from system(CMD, ARGS) back to system(EXPR) that fixed it. die doesn't do anything with a file or directory in that code, so i can't see it being the problem. maybe ActivePerl only likes the monadic (one argument) form of system.

      update: i may have figured it out. i think to do it my way, you would have to say 'TIME.EXE' or whatever the full name of the executable is because it isn't passed to COMMAND.COM to be resolved.