Hi Berndt,
        you wrote...

> simple question, how can I copy file type, creator and icon  along with a file.
> 
> 
>      #!/usr/bin/perl
     use File::Copy;

     copy("/private/var/root/Desktop/xxx/test1.doc", 
"/private/var/root/Desktop/yyy/test2.doc");
> 
> copies just the file, but the resulting test2.doc has lost the icon, file type and 
> creator. I think there must be a way, which I simply dont now. 

If you haven't already done so, get MacOSX::File from CPAN 
(http://search.cpan.org/author/DANKOGAI/MacOSX-File-0.65/) 
and install it on your machine. From "perldoc MacOSX::File::Copy"
we have...

DESCRIPTION
       MacOSX::File::Copy provides copy() and move() as in
       File::Copy.  Unlike File::Copy (that also comes with MacOS
       X), MacOSX::File::Copy preserves resouce fork and Finder
       attirbutes.  Consider this as a perl version of CpMac and
       MvMac which comes with MacOS X developer kit.

Having installed the module you can use something like the following:

#!/usr/bin/perl -w
use strict;
use MacOSX::File::Copy;
my $srcpath='/Users/pmccann/junk/longlines.lis';
my $dstpath='/Users/pmccann/junk/morelonglines.lis';
copy($srcpath, $dstpath) or die "No luck: $!";

Cheers,
Paul

Reply via email to