++McDarren, Tim, graff, Browser

McDarren: Yes I was thinking of truncating the output from top but it's tricky depending on whether hyperthreading is on and SMP view is on, etc. I guess I could just do a head--would open(TOP, "top -b -n 1 | head -n 10 |")work?. For that matter, would
foreach my $l (`top -b -n 1`){ #or, for that matter, foreach(`top -b -n 1 | head -n 10`)? #the code goes here }
work?
Browser, I don't quite get how doing assignments like $stats{$1}=$2 would eventually make keys( %hash ) == values( %hash ) true. The values I am picking off from the data are mostly numbers, while the keys are strings I made up that describe what the numbers are.
I do kind of like the idea of making the list of keys immutable. But, since the values for the keys are fixed ahead of time (in my mind, anyway) and do not exist in the data I am parsing, I don't quite get the practical use of that in this particular instance.

But, it is 4 am here and I am punchy so I could be missing the obvious (like don't predeclare the hash keys).

Finally, since the bottleneck here is waiting for top to finish (and I choose top because it's "one-stop shopping" for the stats I want), could we background the piped open, (as open(TOP, "top -b -n 1 & |")), theoretically allowing us to start reading the first few lines before the whole list of tasks is even done being written?

Thanks,
Terrence

I like computer programming because it's like Legos for the mind.

In reply to Re: How best to tell when my hash is "full" (all values defined)? by OfficeLinebacker
in thread How best to tell when my hash is "full" (all values defined)? by OfficeLinebacker

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.