Perl program to obtain a machine's memory usage

I am trying to use the below code to obtain the memory usage (used, unused, etc) of a machine. I need to use CPAN module (not system command like "free -m").

#myprog.pl=====
#!/usr/bin/perl
use Sys::MemInfo qw(totalmem freemem totalswap);
print "total memory: ".(&totalmem / 1024)."\n";
print "free memory:  ".(&freemem / 1024)."\n";
print "total swap: ".(&totalswap / 1024)."\n";
print "free swap:  ".(Sys::MemInfo::get("freeswap") / 1024)."\n";
#======

But I get error that the module Sys::MemInfo does not exist. Could you please assist me to resolve the issue. It is urgent. Thank you.
toookiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
cpan install Sys::MemInfo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShajiCommented:
If the above command 'cpan install Sys::MemInfo' doesn't work for some weird reasons, then please try the following

Step 1

cpan App::cpanminus

Step 2

cpanm Sys::MemInfo
toookiAuthor Commented:
Thank you. When I try the command 'cpan install Sys::MemInfo' , I get all kind of errors. I could not follow the alternatives. cpan App::cpanminus is this a command on the command line -- did not work. Thank you.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

ozoCommented:
What kinds of errors?
ShajiCommented:
toooki, please answer the following questions

1) Which version of Perl are you using?
2) On what platform are you running Perl?
3) What kind of errors are you getting? Please provide a screenshot of the terminal / errors
Suhas .Senior QA ManagerCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- ozo (http:#a40662893)
-- Shaji (http:#a40663295)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

suhasbharadwaj
Experts-Exchange Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.