laziness, impatience, and hubris | |
PerlMonks |
Using dynamic operators in an if() statementby captkirk (Acolyte) |
on Aug 22, 2006 at 04:34 UTC ( [id://568758]=perlquestion: print w/replies, xml ) | Need Help?? |
captkirk has asked for the wisdom of the Perl Monks concerning the following question:
Forgive me, monks. My copy of Learning Perl, The Perl Cookbook, and Programming Perl is buried in a storage locker.
I'm currently working on a simple script that watches for processing that hog the CPU. I'm not really interested in monitoring CPU time. I want to take the "ps" output from a Linux system, snap up the PIDs of processes "currently" using > $percentage of the CPU, sleep for a bit, and repeat the process. After a few loops, I want to kill these processes. I'm getting stuck at using a custom if() statement. I have a neat and clean variable at the top of the script: $operator = '> 98.0'; This doesn't seem to work in this context: if ($consumption $operator) { do something; } I know there's a way to achieve this, but I don't remember how. Any help, is as always, very much appreciated. Thanks guys!
Back to
Seekers of Perl Wisdom
|
|