[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] file copying/file handles



Hi;
I'm having trouble getting the Perl copy command to work for me. I have a little script below to copy a specified file from one folder to another. It dies on the copy command. There is an incomplete file created in the 'receiving' folder. This file has a generic document icon and is identified as a "MPW document" when I ask for the file info. Can someone please explain why?
I am also wondering what the "*" is doing preceeding the file handle. Why won't just specifying the file handle itself work? (I got this syntax from a Unix friend.)

#! perl -w
use File::Copy;

$file_to_read = "Mac Reid:desktop folder:thisdir:file 1";
$file_to_write = "Mac Reid:desktop folder:thatdir:file 1";

open (FILE_TO_READ, $file_to_read) or
die "Could not open file to read.\n";

open (FILE_TO_WRITE, ">$file_to_write") or
die "Could not open file to write.\n";

copy (\*FILE_TO_READ, \*FILE_TO_WRITE) or
die "Could not copy file.\n";

close (FILE_TO_READ);

close (FILE_TO_WRITE);

# End of script.

Jack Reid

Electronic Systems Developer

---------------------------------------------------------------
Email: jreid@fore.com Phone: 412.742.7894 Fax: 412.742.7900

FORE Systems, Inc
1000 FORE Drive
Warrendale, PA 15086-7502

Visit Fore on the WWW at http://www.fore.com

---------------------------------------------------------------

***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch