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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



wilsonee
New User

Oct 16, 2011, 12:42 AM

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

Hi,

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.

Thanks.

Wilson.


FishMonger
Veteran / Moderator

Oct 16, 2011, 7:36 AM

Post #2 of 2 (321 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).

http://search.cpan.org/~burak/Sys-Info-Base-0.7802/lib/Sys/Info/Device/CPU.pm

 
 


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

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