in reply to Time and Date Output

Here is one from the top of the head:

#!/usr/bin/perl -w use strict; use POSIX qw(strftime); my $date = strftime "%Y-%m-%d %H:%M:%S", localtime(time); open(OUT, ">myfile.date") or die "Oopsy: $!"; print OUT $date,"\n"; close(OUT);

Leonid Mamtchenkov aka TVSET

Replies are listed 'Best First'.
Re: Re: Time and Date Output
by Limbic~Region (Chancellor) on Jul 20, 2003 at 01:08 UTC
    TVSET,
    hmmm - I'm too lazy for that
    perl -e 'print scalar localtime' > myfile.date
    Just change the single quotes to double quotes if it is on Win32.

    Cheers - L~R

      Bah, you call that lazy? :)

      $ date > myfile.date

      Even the perl version's shorter.

      $ perl -e 'print `date`' > myfile.date
        I am inclined to consider your laziness as false laziness. The problem is that while you type less characters, you cause the CPU to work more:
        use Benchmark; timethese(-2, { inhouse => sub { $_ = scalar localtime }, outsource => sub { $_ = `date` }, });

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)