in reply to time2string

Perhaps useful to you. All hail Time::Duration.

#!/usr/bin/perl -w use strict; use Time::Piece; use Time::Duration; use IO::File; my ( $uptime ) = ( IO::File->new('/proc/uptime') or die "No! Can't open!: $!\n" )->getline =~ /^ (\d[\d.]+) \s+ (\d[\d.]+)$/x or die "Invalid uptime!\ +n"; my $now = Time::Piece->new; my $boot = $now-$uptime; printf <<"EOF", duration($uptime), $boot->cdate, $now->cdate; Uptime: %s Boot: %s Now: %s EOF
-- Iain, aka Koschei.

Replies are listed 'Best First'.
Re: Re: time2string
by rendler (Pilgrim) on Jul 22, 2002 at 03:33 UTC
    So module happy... *shakes head* ;)

      I *like* modules =)

      Anyway, that code is normally buried somewhere in a mod_perl handler, so it's not as expensive as it looks. At least it's succinct =)

      -- Iain, aka Koschei.