Click here to get back home

FAQ 5.5 How can I copy a file?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
FAQ 5.5 How can I copy a file? PerlFAQ Server 03-10-2008
Posted by PerlFAQ Server on March 10, 2008, 3:03 pm
Please log in for more thread options
This is an excerpt from the latest version perlfaq5.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

5.5: 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 portable 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.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.

Similar ThreadsPosted
Use of CGI.pm filehandle with File::Copy::copy in taint mode May 5, 2006, 3:57 pm
"copy" from File::Copy fails but returns success October 16, 2007, 4:43 am
File::Copy giving "Bad File Descriptor" from sysread October 3, 2004, 11:33 am
File::Copy works, File::NCopy doesn't September 13, 2005, 1:56 pm
file copy November 19, 2004, 2:45 pm
FAQ 5.5 How can I copy a file? May 2, 2005, 5:03 pm
FAQ 5.5 How can I copy a file? July 18, 2005, 4:03 pm
FAQ 5.5 How can I copy a file? September 22, 2005, 4:03 pm
FAQ 5.5 How can I copy a file? December 11, 2005, 11:03 pm
FAQ 5.5 How can I copy a file? January 21, 2006, 6:03 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap