File::Copy - Copy files or filehandles
use POSIX; use File::Copy cp;
The Copy module provides two functions (copy and copydir)
The copy function 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. Obviously, if the first argument is a filehandle of some sort, it will be read from, and if it is a file name it will be opened for reading. Likewise, the second argument will be written to (and created if need be). If the first argument is the name of a directory, this function simply calls copydir.
An optional third parameter can be used to specify the buffer size used for copying. This is the number of bytes from the first file, that wil be held in memory at any given time, before being written to the second file. The default buffer size depends upon the file, but will generally be the whole file (up to 2Mb), or 1k for filehandles that do not reference files (eg. sockets).
You may use the syntax
Returns 1 on success, 0 on failure. $! will be set if an error was encountered.
copydir takes two directory names. If the second directory does not exist, it will be created. If it does exist, a directory will be created in it to copy to. Copydir copies every file and directory from the source directory (first parameter) to the destination directory (second parameter). The structure of the source directory will be preserved, and warnings will be issued if a particular file or directory cannot be accessed or created.
copydir returns true on success and false on failure, though failure to copy a single file or directory from the source tree may still result in ``success''. The return value simply indicates whether or not anything was done.
File::Copy was written by Aaron Sherman <firstname.lastname@example.org> in 1995.