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, wouldwork?foreach my $l (`top -b -n 1`){ #or, for that matter, foreach(`top -b -n 1 | head -n 10`)? #the code goes here }
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,
|
|---|