in reply to How best to tell when my hash is "full" (all values defined)?

++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.