Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: time2string

by Koschei (Monk)
on Jul 22, 2002 at 02:41 UTC ( [id://183921]=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://183921]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-13 09:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found