in reply to Re: Is there a better way to print time in a HH:MM:SS format than sprintf
in thread Is there a better way to print time in a HH:MM:SS format than sprintf

I thought about using strftime but it would give me the same 'problem': provide a format string

I was looking actually for a module that would show HH:MM:SS by default.

--
if ( 1 ) { $postman->ring() for (1..2); }
  • Comment on Re^2: Is there a better way to print time in a HH:MM:SS format than sprintf

Replies are listed 'Best First'.
Re^3: Is there a better way to print time in a HH:MM:SS format than sprintf
by strat (Canon) on Feb 03, 2006 at 09:12 UTC

    Well, the POSIX::strftime way is shorter than printf:

    use POSIX; print strftime("%H:%M:%S", localtime);
    since time (i.e. Now) is the default for localtime. And if you wrap this into a sub, its usage is even shorter:
    sub TimeHMS { my $time = scalar(@_) ? shift(@_) : time; return strftime( "%H:%M:%S", localtime($time) ); } # TimeHMS print TimeHMS();

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"