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

I am a new MAC user and new to PERL. I would like to install Date::Calc on my Mac but unsure of how to go about it. I downloaded Image-Grab-1.1.tar.gz. The readme file says I need to have some other modules installed already: Installation: You must have the following modules already installed: Digest::MD5 2.07 HTML::Parser 2.20 HTML::Tree 0.51 MIME::Base64 2.11 URI 1.02 libnet 1.0606 libwww-perl 5.43 How can I tell if I have these modules already? Can I really screw up my OS by installing this module incorrectly? Thanks for any help. catmos

2004-11-24 Edited by Arunbear: Changed title from 'Date::Calc', as per Monastery guidelines

Replies are listed 'Best First'.
Re: How to install Date::Calc on a Mac
by neilh (Pilgrim) on Nov 23, 2004 at 04:00 UTC
    CPAN is your friend.
    perldoc CPAN
    But essentially
    perl -MCPAN -e 'install Date::Calc'
    or
    perl -MCPAN -e shell install Date::Calc install Image::Grab
    The beauty of using the CPAN shell is that it will install the prerequisites for you.

    Neil

Re: How to install Date::Calc on a Mac
by steves (Curate) on Nov 23, 2004 at 04:02 UTC

    The standard procedure for installing all CPAN modules is basically the same:

    1. Copy the tar/gzip archive to your local machine;
    2. Unpack the tar/gzipped file contents;
    3. Go to the top level of the unpacked directory;
    4. Run the command perl Makefile.PL;
    5. Run the command make;
    6. Run the command make test;
    7. Run the command make install.

    You may find some (mostly older) modules that have slightly different build procedures. If so, those will be documented in one of the unpacked files, usually with a name like README.

    If there's a dependency, you'll usually be told in step (3), but sometimes not until step (4). For any required dependencies, you just follow the same procedures. That can, of course, lead to more dependencies. If any step fails, you typically do not want to proceed until you figure out why and fix it. I have found cases where some tests during the make test phase fail where it was okay for me to continue on after doing some analysis.

    I pick a fixed root directory for all my downloaded CPAN unpacked archives (e.g., /usr/local/src/cpan). That way I can automate some of it and have a quick look at what I've downloaded and (probably) installed.

    Normally, you will not break anything by installing new modules that don't already exist. If the make process tells you you need a newer version, then you may hit issues. In practice, I've only had one issue like that I can recall in 5+ years of downloading and installing CPAN modules. If you want to be really paranoid, you can create an entirely different code path and access it by modifying Perl's @INC path list.

    The caveat: I'm not a MAC user so I may be missing some some system dependency there.

    There are also packages that help automate the whole process, including finding, downloading, and installing dependencies. I'll let someone more familiar with those explain them.

Re: How to install Date::Calc on a Mac
by jdalbec (Deacon) on Nov 23, 2004 at 04:02 UTC
    How can I tell if I have these modules already?
    In many cases you can type perl -M<module> (e.g, perl -MDigest::MD5) and perl will either pause waiting for input (if you have the module installed) or it will issue an error message (if you don't have it installed). That won't work for libnet or libwww-perl but should work for the other modules you mention.

    Also I believe most modules will warn you about existing versions of the same module when you build them.

      In many cases you can type perl -M<module> (e.g, perl -MDigest::MD5) and perl will either pause waiting for input (if you have the module installed) or it will issue an error message (if you don't have it installed).

      I use to do perl -M<module> -e exit in those cases, so that it won't pause. Or, when I have to test for many modules and using a Bourne-like shell in UNIX (e.g.: bash):

      for MODULE in First::Module Second::Module Third::Module ; do perl -M$MODULE -e exit ; done

      Ciao!
      --bronto


      In theory, there is no difference between theory and practice. In practice, there is.
Re: How to install Date::Calc on a Mac
by tachyon (Chancellor) on Nov 23, 2004 at 04:40 UTC
Re: How to install Date::Calc on a Mac
by Cody Pendant (Prior) on Nov 23, 2004 at 04:48 UTC
    You may not be able to install or use some Perl modules if you haven't installed the Developer Tools.

    They are on your Mac OS CDs/DVDs, and they are also downloadable from the apple website.

    If you haven't installed them yet, and got lots of space on your hard disk, just install the lot.



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
    =~y~b-v~a-z~s; print
Re: How to install Date::Calc on a Mac
by bageler (Hermit) on Nov 23, 2004 at 04:17 UTC
    just do this:

    sudo perl -MCPAN -e 'install Date::Calc'

    went without a hitch when I installed it on my powerbook. If you haven't already, you may want to upgrade your system perl to 5.8.x from the system default.