Thanks for the explanation. I agree with you but I still think the application of the principle in this case isn't merited.

If you want your computer to tell you how many seconds its been up...

Parsing it into seconds wasn't requested. I agree that it might be what was wanted. People often don't ask for what they really want. It is just as likely, however, that he wanted to display the English form on a web page or some such. In any case he wanted to collect the time, the number of users, and the load averages as well.

The fact remains that using uptime to retrieve these pieces of information provides a relatively stable and convenient interface and is able to be parsed by the same regex on at least the several platforms that I tested and probably many more. It might be a little messy (like a lot of the world) but Perl excels at dealing with messiness.

In defense of my Updates, all I can say is I got it right the first time but I retyped it wrong. Twice. I would have cut and pasted but I was using the console on a different machine. There really was no excuse for such sloppiness and I've put a link to the node on my home node as a reminder to myself to take my time and get it right. ;-)

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Re5: Parsing 'uptime' output by sauoq
in thread Parsing 'uptime' output by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.