Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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=> ./test1.pl Can't locate Date/Calc.pm in @INC (@INC contains: /home/ss1880/Date-Ca +lc-6.3/li. BEGIN failed--compilation aborted at ./test1.pl 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;

Comment on Simple perl question
Select or Download Code
Re: Simple perl question
by toolic (Chancellor) on Nov 08, 2012 at 14:05 UTC
      Almost the same error :
      Can't locate Carp/Clan.pm 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 +alc.pm li. BEGIN failed--compilation aborted at /home/ss1880/Date-Calc-6.3/lib/Da +te/Calc.p. Compilation failed in require at test1.pl line 3. BEGIN failed--compilation aborted at test1.pl 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 (Curate) 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...

    And:

    Karls-Mac-mini:~ karl$ ls -hlrt /Library/Perl/5.12 total 216 -r--r--r-- 1 root wheel 31K 26 Feb 2011 PPI.pm -rw-r--r-- 1 root wheel 33B 11 Okt 2011 AppendToPath -r--r--r-- 1 root wheel 543B 4 Apr 2012 oo.pm -r--r--r-- 1 root wheel 20K 18 Jun 13:32 Carp.pm -r--r--r-- 1 root wheel 8,9K 9 Sep 03:15 strictures.pm -r--r--r-- 1 root wheel 946B 11 Sep 20:24 ok.pm -r--r--r-- 1 root wheel 23K 23 Okt 17:27 Moo.pm 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1002901]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-08-30 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls