#!/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