Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

CPU informations - strange errors

by POHI (Initiate)
on Oct 21, 2015 at 11:17 UTC ( [id://1145541]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks, I have to get some CPU informations independent (!) from OS. I saw many posts about that but I get a strange error and I hope you can help me.

What I do:

I get this Package http://search.cpan.org/~burak/Sys-Info-Base-0.7804/lib/Sys/Info/Device/CPU.pm and did what it's written about. I use cygwin.
use Sys::Info; use Sys::Info::Constants qw( :device_cpu ); use Sys::Info::Driver::Unknown::Device::CPU; # for cygwin (?) my $info = Sys::Info->new; # alternative 1 http://search.cpan.org/~burak/Sys-Info-Base-0.7804/lib +/Sys/Info/Device/CPU.pm my $cpu = $info->device( CPU => %options ); #line 19 # alternative 2 $info->device( 'CPU' ); printf "CPU freq %s MHz\n", $cpu->speed; #line 22 printf "%d CPUs\n" , $cpu->count ;

What I get:

# alternative 1 Global symbol "%options" requires explicit package name at pcData.pl l +ine 19. Execution of pcData.pl aborted due to compilation errors. #alternative 2 Odd number of elements in hash assignment at /usr/lib/perl5/site_perl/ +5.14/Sys/Info/Driver/Unknown/Device/CPU/Env.pm line 26. Use of uninitialized value $family in hash element at /usr/lib/perl5/s +ite_perl/5.14/Sys/Info/Driver/Unknown/Device/CPU/Env.pm line 86. Use of uninitialized value in printf at pcData.pl line 22.

What should I do?

Have someone a hint for me? What options in %options are possible and how I can/should configure it? What means the output in alternative 2? Is this a nice way or is there a nicer way to get this informations? I learned Perl 2-3 weeks ago so sorry for annoying you for this thing if it's a basic topic. :)

Replies are listed 'Best First'.
Re: CPU informations - strange errors
by toolic (Bishop) on Oct 21, 2015 at 12:33 UTC
    Global symbol "%options" requires explicit package name at pcData.pl line 19.
    That means that you use strict;, but you didn't declare the %options hash variable, typically with my.
    What options in %options are possible and how I can/should configure it?
    The module documentation should describe what options are available. I took a quick look through Sys::Info and its other modules, but I didn't find anything relevant. You can look for example code usages, for example in the "t" test directories that come with the distribution. You can also look through the source code. If that doesn't help, contact the module author
    is there a nicer way to get this informations?
    The SEE ALSO section mentions more alternatives than you can shake a stick at.
Re: CPU informations - strange errors
by GotToBTru (Prior) on Oct 21, 2015 at 12:31 UTC

    Perhaps contact the author? I just reviewed the documentation, and I don't see a definition of what should be in %options.

    Dum Spiro Spero
      Thanks for your advice. I'll contact the author.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1145541]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found