File_Copy

# NAME

File::Copy - Copy files or filehandles

# SYNOPSIS

- 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 one function (copy) which 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).

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

When running under VMS, this routine performs an RMS copy of the file, in order to preserve file attributed, indexed file structure, etc. The buffer size parameter is ignored.

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

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

# AUTHOR

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