* Several people on the Perl Trainers suggested adding this answer to perlfaq5.
* I'll update perlfaq.pod once I commit this answer. Index: perlfaq5.pod =================================================================== RCS file: /cvs/public/perlfaq/perlfaq5.pod,v retrieving revision 1.34 diff -u -d -r1.34 perlfaq5.pod --- perlfaq5.pod 3 Jan 2005 18:43:37 -0000 1.34 +++ perlfaq5.pod 3 Jan 2005 19:10:08 -0000 @@ -106,6 +106,22 @@ leaving a backup of the original data from each file in a new C<.c.orig> file. +=head2 How can I copy a file? + +(contributed by brian d foy) + +Use the File::Copy module. It comes with Perl and can do a +true copy across file systems, and it does its magic in +a protable fashion. + + use File::Copy; + + copy( $original, $new_copy ) or die "Copy failed: $!"; + +If you can't use File::Copy, you'll have to do the work yourself: +open the original file, open the destination file, then print +to the destination file as you read the original. + =head2 How do I make a temporary file name? If you don't need to know the name of the file, you can use C<open()>