Page 1 of 1

Perl Modules from CPAN

Posted: Sat Apr 13, 2013 7:43 pm
by nemo096
I am attempting to use my Raspberry Pi as the brains of an AI I am currently scripting

I have used a CPAN module (DateTime) to get the hour so I can check if it is between 2 values to set a response to morning/afternoon/evening/night. When using the built-in function I was not able to get it working

It now works using DateTime but I have no idea how to install Perl modules from CPAN on to the Pi

Any help please or suggestions?


Re: Perl Modules from CPAN

Posted: Tue Apr 16, 2013 4:19 pm
by bobblestiltskins
Firstly check whether the module has been packaged for debian e.g. aptitude search lib | grep perl
will give a large list of packages. If the one you want is listed here then install it via aptitude install. If, however, it is not packaged, then as root, do perl -MCPAN -e 'install Name::Of::Module'

Re: Perl Modules from CPAN

Posted: Wed Apr 17, 2013 4:21 pm
by scrapheap
DateTime is great module and well worth using if you have any complex time based stuff to do, but for simply checking the machines local time you could just use the localtime ( function

Code: Select all

my ($sec,$min,$hour)=localtime();
print "$hour\n";

Re: Perl Modules from CPAN

Posted: Wed Apr 17, 2013 6:50 pm
by nemo096
I am using DateTime at the minute to get the hour and put it through a few if statements so it will print morning afternoon evening or tonight - transferring my AI type script and updating it to my Pi

Will try that code as soon as I can thanks