|
General Details
|
|
Perl
|
|
Posted 1.17 Year Ago
|
|
145 Views
|
|
Received 0 Ratings
|
|
[perl] [*nix] Uptime
Description
This is a little perl script made for *nix systems. It takes the uptime (which is in seconds format) and shows it as hh:mm:ss (hours:minutes:seconds)
if hours/minutes/seconds are/is less than 10, a zero digit ('0') is put, so the output is pretty.
I personally don't know much shell scripting so I made it in perl to show the uptime on my wmii bar.
In the screenshot, I use DWM, put that script to run in the .xinitrc and it's the first 09:mm:ss thing from the left, at the right side of the bar at the bottom.
Technical
System Requirements: Modern UNIX system and Perl interpreter.
You may need to change the Perl interpreter line to where the perl binary is located in your system.
For example:
change `#!/bin/perl` to `#!/usr/bin/perl`
Source Code
Comments
| Please login to post comments. |
|
|
I've learn't some perl... the syntax is the same... but perl adds a few new/different things... it's those sort of things that you forget.
Like perl has eq to compare strings... php has ===/==... perl is also very context sensitive... php isn't... perl has shortcuts like qw (quoted words)... and perl allows different opening and closing things like qw// or qw"" or qw&& etc... all work the same... php can't... perl doesnt require brackets around functions... php does... perl allows the same name for a function, variable, etc... php can't... perl uses default variables... php doesn't have them... and so on...
It's that stuff you forget ;-)
Kind regards,
Scott
|
|
|
if you know cpp/php you can't forget it... the syntax is the same :-p
|
|
|
Neither do i really... just finished a book about perl... been doing perl for about 3 to 4 weeks... it's not a very nice language so i'd imagine i'll forget it in a few years.
Kind regards,
Scott
|
|
|
I don't know perl that much... :-)
|
|
|
Nice, but how does that differ from:
http://search.cpan.org/~barabas/Sys-Load-0.2/Load.pm
or more specifically:
use Sys::Load qw/uptime/;
print "System uptime: ", int uptime(), "\n";
Kind regards,
Scott
|
More "Perl" Source Codes By This Author
Recently Posted "Perl" Source Codes
Recently Rated "Perl" Source Codes
|