File::Copy

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



NAME
       File::Copy - Copy files or filehandles

USAGE
               use File::Copy;

               copy("file1","file2");
               copy("Copy.pm",\*STDOUT);'

               use POSIX;
               use File::Copy cp;

               $n=FileHandle->new("/dev/null","r");
               cp($n,"x");'


DESCRIPTION
       The Copy module provides two functions (copy and copydir)

       copy

       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
       encountered.

       copydir

       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.

SEE ALSO
       the File::Tools manpage

AUTHOR
       File::Copy was written by Aaron Sherman <ajs@ajs.com> in 1995.












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