Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Simple perl question

by nua7 (Initiate)
on Nov 08, 2012 at 14:00 UTC ( #1002901=perlquestion: print w/replies, xml ) Need Help??
nua7 has asked for the wisdom of the Perl Monks concerning the following question:

Hi All Perl experts, I am new to Perl and got a real stupid question. We are trying to install the Date:Calc package for some calculations with dates.The security guys mentioned they won't install it as root in /usr/bin/perl but have asked us to install it in any directory and use it from there. Here's the sample program that I created to test this scenario.But I am getting an error.Any help will be appreciated.
(rk3388) mpdev1=> ./ Can't locate Date/ in @INC (@INC contains: /home/ss1880/Date-Ca +lc-6.3/li. BEGIN failed--compilation aborted at ./ line 4.
#!/usr/bin/perl use lib '/home/ss1880/Date-Calc-6.3/lib/Date/'; use Date::Calc; my @today = (localtime)[5,4,3]; $today[0] += 1900; $today[1]++; my @birthday = (1980, 4, 3); my $days = Delta_Days(@birthday, @today); print "I am $days days old\n"; exit 0;

Replies are listed 'Best First'.
Re: Simple perl question
by toolic (Bishop) on Nov 08, 2012 at 14:05 UTC
      Almost the same error :
      Can't locate Carp/ in @INC (@INC contains: /home/ss1880/Date-Ca +lc-6.3/li. BEGIN failed--compilation aborted at /home/ss1880/Date-Calc-6.3/lib/Da +te/Calc/P. Compilation failed in require at /home/ss1880/Date-Calc-6.3/lib/Date/C li. BEGIN failed--compilation aborted at /home/ss1880/Date-Calc-6.3/lib/Da +te/Calc.p. Compilation failed in require at line 3. BEGIN failed--compilation aborted at line 3.
        Before you do anything else, read Writeup Formatting Tips (as I already advised), and update your posts using "code" tags for your error messages and Perl code. Your posts are difficult to understand.
        Those error messages are incomplete. My best guess is that Carp::Clan is not installed yet.
Re: Simple perl question
by karlgoethebier (Monsignor) on Nov 08, 2012 at 19:31 UTC

    Another approach to this issue:

    Isn't Date::Calc in core? It should be available with your standard perl installation, regardless you use Linux or M$-Dog or something else.

    If it is not there for any strange reasons consider this (after download in the unpacked src directory of Date::Calc):

    perl Makefile.PL PREFIX=/path/to/your/lib

    Say then:

     make && make test && make install

    Then, in your app say:

    use lib q(/path/to/your/lib); use Date::Calc;

    And i can't see any security problems installing modules as root. How else should this be done in the default places?. E.g. on my Mac:

    Karls-Mac-mini:~ karl$ perl -e 'print join(qq(\n), @INC);' /sw/lib/perl5 /sw/lib/perl5/darwin /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 # and many more...


    Karls-Mac-mini:~ karl$ ls -hlrt /Library/Perl/5.12 total 216 -r--r--r-- 1 root wheel 31K 26 Feb 2011 -rw-r--r-- 1 root wheel 33B 11 Okt 2011 AppendToPath -r--r--r-- 1 root wheel 543B 4 Apr 2012 -r--r--r-- 1 root wheel 20K 18 Jun 13:32 -r--r--r-- 1 root wheel 8,9K 9 Sep 03:15 -r--r--r-- 1 root wheel 946B 11 Sep 20:24 -r--r--r-- 1 root wheel 23K 23 Okt 17:27 drwxr-xr-x 3 root wheel 102B 27 Okt 13:46 B drwxr-xr-x 7 root wheel 238B 27 Okt 13:48 DateTime # and many more...

    As you can see everything belongs to root:wheel but the rest can use it anyway. This is the default: Stuff belongs to root:wheel in that directories but is used under your UID if you call it.

    A thing one might think about is: I don't want to mess up my default @INC. Then use PREFIX as described above.

    BTW: Consider to take a look at Datetime. And trust toolic.

    As always, i hope i didn't miss something.

    Regards, Karl

    P.S.: I did something wrong, s***t. If installing as root, make install as root , or root does it himself, sorry for that - sink before you type ;-)

      Isn't Date::Calc in core?
      No (as of perl 5.14):
      corelist Date::Calc Date::Calc was not in CORE (or so I think)

        ...right for my Mac too using v5.12.3:

        Karls-Mac-mini:~ karl$ corelist Date::Calc Date::Calc was not in CORE (or so I think)

        I installed it and forgot about...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1002901]
Approved by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-02-21 15:50 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (283 votes). Check out past polls.