avo has asked for the wisdom of the Perl Monks concerning the following question:

Good day monks, I need to design long running perl program that is using a lot of CPU, but I want to limit the execution of the code only when the PC's CPU is currently idle, so I don't stop other processes from running smooth. Is there any way I can (cross platform) get information on the current CPU usage via Perl ? I would gladly accept any code samples as well. I was thinking of using POE ... but any ideas are more than welcome. Thanks a lot for your response!

Replies are listed 'Best First'.
Re: when CPU is idle
by ikegami (Patriarch) on Sep 02, 2005 at 09:14 UTC
    I don't think that programs that should only run when idle check the CPU usage. They simply tell the OS to set their priority to the lowest level. You may want to look into that instead.
Re: when CPU is idle
by xdg (Monsignor) on Sep 02, 2005 at 10:03 UTC

    Searching CPAN for "nice" reveals Proc::NiceSleep, which appears to be along the lines of what you're looking for.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.