Copy(3)               User Contributed Perl Documentation              Copy(3)

       File::Copy - Copy files or filehandles

               use File::Copy;


               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 use File::Copy "cp" to get at the "cp" alias for
       this function. The syntax is exactly the same.

       Return value:

       Returns 1 on success, 0 on failure. $! will be set if an error was


       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.

       Return value:

       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.

       the File::Tools manpage

       File::Copy was written by Aaron Sherman <> in 1995.

3rd Berkeley Distribution    perl 5.005, patch 03                      Copy(3)