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

I have been trying to put together a perl script that will copy a directory on OS X that handles the files, subdirectories and also handles the file metadata. I have "hacked" together a solution.

I used the package File::Copy::Recursive

Modified it to use the copy function in

MacOSX::File::Copy

and it works, all files and metadata are copied. Now for the question. I noticed that the module Recursive.pm is in

/System/Library/Perl/darwin

whereas the module MacOSX::File::Copy.pm is in

/Library/Perl/darwin

Why are there two darwin directories?

Replies are listed 'Best First'.
Re: Mac Perl Package Question
by Tanktalus (Canon) on Apr 11, 2005 at 23:42 UTC

    Not being a Mac user, I'm going to guess that MacOSX::File::Copy is shipped with the perl that comes with MacOSX. And that all the rest of your modules that came shipped with MacOSX are also in /Library/Perl and/or /Library/Perl/darwin.

    The /System/Library/Perl and /System/Library/Perl/darwin directories hold all user-installed modules and user-installed darwin-specific code (whether that's modules or compiled XS code).

    This is little different from the unix platforms that have a "site_perl" path for user-installed modules (and, on some linux distros, a vendor_perl path for vendor-supplied modules, which is where modules that are needed by the vendor applications would live).

    Update: As per below, I guessed backwards. Well, I did say I wasn't a Mac user :-) Either way, the reason for the two "darwin" directories is for this separation of what comes with the perl distribution vs what is user-installed.

      The /System/Library/Perl and /System/Library/Perl/darwin directories hold all user-installed modules and user-installed darwin-specific code (whether that's modules or compiled XS code).

      Actually, it is the other way around: /System/Library/Perl is the vendor_perl directory, and site_perl is /Library/Perl.

      Apple-shipped stuff is in /System/Library/Perl, CPAN modules go to /Library/Perl.

      And starting with Mac OS X 10.3, under both of these directories are Perl-version-specific subdirectories (so that you can have different Perl version concurrently).

      The Perl that ships with 10.3 has this search path:

      @INC: /System/Library/Perl/5.8.1/darwin-thread-multi-2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/Perl .

        I'll back Tholosophy on this one -- don't mess with stuff in /System. You should do as CPAN does, and drop stuff in /Library/Perl. The big clue is that /Library is group writable:

        [mildly:~] oneiros% ls -ald /System /System/Library /Library drwxrwxr-x 41 root admin 1394 Feb 17 08:01 /Library drwxr-xr-x 4 root wheel 136 Dec 15 19:12 /System drwxr-xr-x 52 root wheel 1768 Feb 19 09:45 /System/Library

        This also goes for user-installed fonts, screen savers, pref panes, startup items, etc. -- put them in the appropriate directories in /Library not /System/Library