thank you to both of you for guiding and enlightning replies.

I have learned quite a bit through this, and have found the thrill of my first real hash.

Here is how the code currently stands (as always, a work in progress):

#!/usr/bin/perl -w use strict; ## usage information # $0 UPSNAME HOSTNAME DATAPOINT # where DATAPOINT can be any of # UTILITY - the number VAC utility power is providing # LOADPCT - the percentage of the maximum load # BATTPCT - percent of total battery charge available # RUNTIME - approx. number of minutes of battery life # note that DATAPOINTs *must* be specified in all caps my ($key, $val, %upsdata); foreach (`/usr/local/bin/upsc $ARGV[0]\@$ARGV[1]`) { ($key, $val) = /(\w+):\s(.*)(\n)?/; $upsdata{$key} = $val; }; if ($ARGV[2]) { print "$upsdata{$ARGV[2]}\n"; } else { print "utility is $upsdata{UTILITY}\n"; print "loadpct is $upsdata{LOADPCT}\n"; print "battpct is $upsdata{BATTPCT}\n"; print "runtime is $upsdata{RUNTIME}\n"; };

In reply to Re: Re: scalar dereferencing by jamgill
in thread scalar dereferencing by jamgill

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.