CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
OO Perl CPU info from various Unix


New User

Oct 16, 2011, 12:42 AM

Post #1 of 2 (572 views)
OO Perl CPU info from various Unix Can't Post


I would like some recommendations as to how I should approach this. Im trying to write a script where I need,

find number of CPUs
cpu model
cpu speed

for hp-ux, aix, solaris. I would have to use different sub routines to get what I need, ie, Solaris I would use a different command to get CPU info to HP-UX.

sub hpux_cpu_no {}
sub solaris_cpu_no {}
sub aix_cpu_no {}

Since the information I need is the same irrespective of OS, how would I go about writing code that would minimise repetition. I found some suggestions of using Dispatch table but not sure how I would implement this.

I was trying to use OS variable as part of the subroutine

call $os_cpu_no subroutine to get the info for correct OS.
where $os = hpux, solaris, aix, not even sure if this is possible or a good idea.

I would like to use OO Perl.



Veteran / Moderator

Oct 16, 2011, 7:36 AM

Post #2 of 2 (562 views)
Re: [wilsonee] OO Perl CPU info from various Unix [In reply to] Can't Post

You can retrieve the OS from Perl's built-in $^O var and for retrieving the cpu info, look at Sys::Info::Device::CPU (I have not used it myself).


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives