nemo096
Posts: 26
Joined: Wed Dec 26, 2012 10:54 am

Perl Modules from CPAN

Sat Apr 13, 2013 7:43 pm

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?

Thanks

bobblestiltskins
Posts: 16
Joined: Wed Aug 29, 2012 11:10 am

Re: Perl Modules from CPAN

Tue Apr 16, 2013 4:19 pm

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'

scrapheap
Posts: 20
Joined: Wed Feb 13, 2013 5:13 pm

Re: Perl Modules from CPAN

Wed Apr 17, 2013 4:21 pm

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 (http://perldoc.perl.org/functions/localtime.html) function

Code: Select all

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

nemo096
Posts: 26
Joined: Wed Dec 26, 2012 10:54 am

Re: Perl Modules from CPAN

Wed Apr 17, 2013 6:50 pm

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

Return to “Other programming languages”