use File::Copy; copy("
dst-file"); copy("Copy.pm", \*STDOUT); use POSIX; use File::Copy 'cp'; $fh = FileHandle->new("/dev/null", "r"); cp($fh, "
The Copy module provides one function,
copy(), that takes two
parameters: a file to copy from and a file to copy to. Either
argument may be a string, a FileHandle reference, or a FileHandle
glob. If the first argument is a filehandle of some
sort, it will be read from; if it is a filename, it will
be opened for reading. Likewise, the second argument will be
written to (and created if need be).
An optional third parameter is a hint that requests the buffer size to be used for copying. This is the number of bytes from the first file that will be held in memory at any given time, before being written to the second file. The default buffer size depends upon the file and the operating system, but will generally be the whole file (up to 2Mb), or 1kb for filehandles that do not reference files (for example, sockets).
When running under VMS, this routine performs an RMS copy of the file, in order to preserve file attributes, indexed file structure, and so on. The buffer size parameter is ignored.
You may use the syntax:
use File::Copy "cp"
to get at the
cp() alias for the
The syntax is exactly
1 on success,
0 on failure;
$! will be set if an error was encountered.