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

Hello, I am new at Perl modules and am having difficulty getting them to work. I get this error Can't locate Date/DateCalc.pm in @INC (@INC contains: Documents/program-bin/dateconvert.pl /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level /Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at dateconvert.pl line 7. BEGIN failed--compilation aborted at dateconvert.pl line 7. when I try to run

#!/usr/bin/perl use strict; use warnings; use Carp; use Date::DateCalc; $date=new Date::Convert::Gregorian(1997, 11, 27); @date=$date->date; Date::Convert::Julian print $date->date_string, "\n";
I used sudo -MCPAN -e 'shell' and then make install to install the modules from CPAN (the installations ran without error), downloaded "command line tools for xcode", have downloaded/upgraded to the latest version of Ruby, Rails, RVM, and installed Homebrew. I am running Lion on OSX. What do I need to do make this module run?

Replies are listed 'Best First'.
Re: Installing modules help
by tobyink (Canon) on Jul 14, 2013 at 01:21 UTC

    If you have multiple versions of Perl installed on your system, maybe your user name and root are each seeing a different one. Compare:

    $ which perl $ sudo which perl

    Also worth comparing:

    $ echo $PERL5LIB $ sudo /bin/sh -c 'echo $PERL5LIB'
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

       $ sudo which perl returned /usr/bin/perl  sudo /bin/sh -c 'echo $PERL5LIB' and  echo $PERL5LIB returned nothing

Re: Installing modules help ( Date::DateCalc )
by Anonymous Monk on Jul 14, 2013 at 01:37 UTC

      Date::DateCalc is from CPAN. The newer versions of Perl do not include this module as standard. Georgian time is the date and time we currently use. The Julian time is the time I wish to convert to. Julian date is part of Date::Convert, which is contained in Date::Calc. Changing the code to

      #!/usr/bin/perl use strict; use warnings; use Carp; use Date::DateCalc; <code> $date=new Date::Convert::Julian(1997, 11, 27); @date=$date->date; print $date->date_string, "\n";

        Date::DateCalc is from CPAN. The newer versions of Perl do not include this module as standard

        No, there is no "Date::DateCalc" module on cpan, it doesn't exist

        Changing the code to

        Well, now you introduce other typos -- that code won't compile, see Read this if you want to cut your development time in half!

Re: Installing modules help
by Anonymous Monk on Jul 14, 2013 at 01:11 UTC
    Where did you install the module? Why is that directory root not in your @INC? Are you using the same perl you used to install the module?
Re: Installing modules help
by kcott (Archbishop) on Jul 14, 2013 at 08:18 UTC

    G'day cyates,

    You appear to have the answer to your immediate problem.

    I started using Mac OS X Lion a couple of years ago and asked this question: "Are there any major Perl issues with Mac OS X Lion?".

    You may find some of the information useful. With regards to the various "Don't use the system Perl" responses, I chose Perlbrew — still happily using that with Perl 5.18.0.

    -- Ken