in reply to Time Conversion
I originally wrote it using an $uptime temporary with a do block initializer, then noticed I can basically switch to a sub by substituting sub uptime for my $uptime = do. Either way makes the code self-documenting.use POSIX qw(strftime); sub uptime { local $/ = " "; open my $fh, '<', '/proc/uptime' or die "Can't open /proc/uptime to read: $!\n"; return scalar <$fh>; } print strftime "Last booted %Y-%m-%d/%H:%M:%S\n", ( localtime( time() - uptime() ) );
Makeshifts last the longest.
|
|---|