|
Posted by Bill H on June 8, 2008, 7:01 am
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 athttp://faq.perl.org.
>
> --------------------------------------------------------------------
>
> 5.5: How can I copy a file?
>
> =A0 =A0 (contributed by brian d foy)
>
> =A0 =A0 Use the File::Copy module. It comes with Perl and can do a true co=
py
> =A0 =A0 across file systems, and it does its magic in a portable fashion.
>
> =A0 =A0 =A0 =A0 =A0 =A0 use File::Copy;
>
> =A0 =A0 =A0 =A0 =A0 =A0 copy( $original, $new_copy ) or die "Copy failed: =
$!";
>
> =A0 =A0 If you can't use File::Copy, you'll have to do the work yourself: =
open
> =A0 =A0 the original file, open the destination file, then print to the
> =A0 =A0 destination file as you read the original.
What is the advantage of using this over using system("cp $original
$new_copy"); (or system("copy $original $new_copy"); on windows)? Is
it faster or is it just "perlish"? Or am I missing something obvious?
Bill H
PS When did Google Groups drop the captcha?
|