Excellent tutorial! The only problem is that I've gotten errors from the regex on three different unixes. I've quadruple-checked my syntax, so i don't think it's that.
the program I'm using with the the module is ...
tie $uptime, 'Uptime';
printf("%20s%-20s\n", "uptime:\t", $uptime->uptime);
printf("%20s%-20s\n", "users:\t", $uptime->users);
printf("%20s%-20s\n", "load(1):\t", $uptime->load('one'));
printf("%20s%-20s\n", "load(5):\t", $uptime->load('five'));
printf("%20s%-20s\n", "load(15):\t", $uptime->load('fifteen'));
printf("%20s%-20s\n", "string:\t", $uptime->as_string);
... and the output I get on an AIX system, a Solaris system, and a Darwin system, is ...
uptime: 21 days, 8:02
Use of uninitialized value in printf at ./dumpuptime.pl line 14.
string: 20:39pm up 21 days, 8:02, 1 users, load
+average: 0.04, 0.03, 0.04
Do I have something wrong, or is the regex in the tutoral off? Thanks, -s-
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.