Next | Program Repair Shop | 64 |
One last example:
Subject: get idle times and format it Date: Fri, 14 Dec 2001 03:55:10 +0100
$line = `top b -n 0 | awk '/idle/ {gsub ("%", "") ; print $3,$5,$7,$9}'`; @data = split(/ /, $line); $user = $data[1]; $system = $data[2]; $nice = $data[3]; $idle = $data[4]
Same problem
($line) = grep /idle/, `top b -n 0`; ($user, $system, $nice, $idle) = ($line =~ m/\d+\.\d+/g);
Note parentheses in ($line)
We also reduced the Perl code substantially
Next | Copyright © 2006 M. J. Dominus |