in reply to Obtaining data from the top command via a pipe
if you want it in perl, probably (other ways of course) want a loop something like:top -b -n 1 | grep ^CPU
while(<PIPE>){ next unless /^CPU.*? ([0-9.]+)% idle, ([0-9.]+)% user/; my ( $idle, $user ) = ( $1, $2 ); ... last; }
|
|---|