Check out Sys::Info, it's a great little module and it is cross-platform. This code is directly from the POD documentation, except the call to $info->device requires just 'CPU', not CPU => %options.
use Sys::Info::Constants qw( :device_cpu );
my $info = Sys::Info->new;
my $cpu = $info->device('CPU');
printf "CPU: %s\n", scalar($cpu->identify) || 'N/A';
printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
printf "There are %d CPUs\n" , $cpu->count || 1;
printf "CPU load: %s\n" , $cpu->load || 0;
This prints on my linux box:
CPU: 2 x Intel(R) Pentium(R) 4 CPU 2.80GHz
CPU speed is 2801.015 MHz
There are 2 CPUs
CPU load: 0.21
It should run on my windows box, but I found out with ActivePerl 5,the latest version was 0.51 as PPMs tend to lag, and I'm not sure how to install a module with XS code from CPAN on Windows.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||