Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Lost in Mac OS X

by Perrmoss (Initiate)
on Sep 20, 2007 at 07:55 UTC ( [id://640066]=perlquestion: print w/replies, xml ) Need Help??

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

Hail Noble Monks,

(This is my first post)

I am an engineer, who has decided to write a program in Perl (in other words I am not an experienced coder). I want the program to work on Mac and Windows, which is why I chose Perl, and I am working on the prototype on my Mac (OS X 10.4.10). I have some Mac-specific questions.

I have got to the point when I need to be able to install modules; DateTime in particular. I have attempted an install in terminal, but I dont think it was successful. Here is what I did...

Open terminal Type sudo perl -MCPAN -e shell Input password Type install DateTime

When I try to find DateTime in the finder, it appears in...

usr/local/ActivePerl-5.8/lib/ActiveState-5.8/DateTime.pm
In an earlier attempt I also attempted to install ActiveState.

Odd thing is, when I type perl -v in terminal, it says I have perl version 5.8.6. I note that ActiveState has perl version 5.8.8

Do I have two versions of perl?

Has DateTime arrived at the right place?

Can I write a 'use DateTime;' type of line in my program (program says cant locate DateTime.pm in @INC)?

Can someone provide a step-by-step guide on how the install should be done?

Thanks in advance

20070922 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Lost in Mac OS X
by Corion (Patriarch) on Sep 20, 2007 at 08:53 UTC

    The Tutorials section has Modules: Hot to Create, Install and Use, which should bring you closer to your goal.

    Basically, you have to decide which Perl will be your "development Perl". I recommend not to use the Perl that came with your operating system (Perl 5.8.6), because system utilities might depend on the exact versions of modules installed there and breaking the system Perl might mean breaking those utilities too.

    You can set up your path environment variable ($ENV{PATH}) so it finds the ActiveState Perl first or you can be explicit about which Perl to invoke by setting up an alias to ActiveState Perl (which is what I recommend).

    Either way, you should then install the Perl modules by using the ActiveState Perl so the modules get installed to ActiveState Perl and not your system Perl:

    /usr/local/ActivePerl-5.8/bin/perl -v # should print 5.8.8 sudo /usr/local/ActivePerl-5.8/bin/perl -MCPAN -eshell # will then install to your AS Perl

    A quick check to see whether a module is installed for a version of Perl is:

    perl -MDateTime -e1 # or more general perl -MSome::Module::Name -e1

    If that runs without a failure, DateTime (or Some::Module::Name) is installed.

Re: Lost in Mac OS X
by graff (Chancellor) on Sep 20, 2007 at 10:24 UTC
    Do I have two versions of perl?

    Evidently. You did say you installed one of them yourself.

    Has DateTime arrived at the right place?

    Whichever perl version is invoked when you do this:

    sudo perl
    is presumably the one that got the DateTime module installed via CPAN.pm -- I'm actually a bit puzzled (maybe I'd be a little worried) if "sudo perl" turned out to be the more recent ActiveState version that you seem to have installed yourself. The current default version of perl that comes with macosx is 5.8.6, as mentioned in a previous reply.

    While I'd personally like to upgrade to 5.8.8, it's not that big an issue for me (this is just my own laptop I'm talking about), I'm content with the version the came with this release of macosx (it handles my needs for doing code development), and I'll look forward to having a newer perl with the next OS upgrade.

    Contrary to one of the earlier replies, I have no qualms at all about installing modules liberally using the perl 5.8.6 that came with the OS. Adding totally new non-core modules will obviously have no impact on any existing scripts; the risk that upgrades to pre-installed modules might break something is unlikely to the point of being a non-issue (though I seldom find a compelling need to install such upgrades for laptop use).

    You should check to make sure that the perl used in your "sudo" environment is the same one you use for normal development and processing. (If you're doing web development with apache on the mac, be sure that apache uses that same version of perl as well.) Use shell interaction to work that out ("find", "locate", "which", "type", "mv", "rm", edit your personal .bashrc if necessary, and so on). Don't use "Finder" for this stuff -- it sucks.

    I can't think of any good reason to use two distinct versions on the one machine (it can be done, but the extra complications would be hard to justify). YMMV.

    Update: I should also mention that I do a lot of development on my macosx laptop (using 5.8.6) for scripts that are meant for production use on freebsd (which is using 5.8.8 now). So long as the development machine and the production machine have the same non-core modules installed, there has never been any problem with portability.

    At worst, I might need to twiddle a path or two in @INC, for modules that I installed as a non-root user on the freebsd system; though it will usually suffice just to make sure my shell PATH and PERLLIB environment variables are properly tailored to each location.

Re: Lost in Mac OS X
by bruceb3 (Pilgrim) on Sep 20, 2007 at 08:45 UTC
    Hi, I don't have a step by step guide, but Perl is installed by default on Mac OS X. The default Perl install is in /usr/bin/perl
    bruce:0:~/tmp $ type perl perl is /usr/bin/perl bruce:0:~/tmp $ ls -l /usr/bin/perl -rwxr-xr-x 1 root wheel 43444 Nov 16 2006 /usr/bin/perl bruce:0:~/tmp $ perl -v This is perl, v5.8.6 built for darwin-thread-multi-2level (with 3 registered patches, see perl -V for more detail)

    It sounds like you have to change your PATH so that the ActiveState Perl is found before the default installation of Perl.

    I can't tell you where ActiveState Perl is installed but I would start with /usr/local/ActiveState/bin/perl judging by the location of the DateTime module.

    You could use the find command, i.e.  find /usr -name perl

Re: Lost in Mac OS X
by kwaping (Priest) on Sep 20, 2007 at 15:57 UTC
    which perl and which cpan should enlighten you to what's happening.

    ---
    It's all fine and dandy until someone has to look at the code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-03-19 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found