SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from RedHat Other perl-5.004-0.1.i386.rpm

File::Copy

Section: Perl Programmers Reference Guide (3)
Updated: perl 5.004, patch 04
Index 

NAME

File::Copy - Copy files or filehandles 

SYNOPSIS

        use File::Copy;
        copy("file1","file2");        copy("Copy.pm",\*STDOUT);'        move("/dev1/fileA","/dev2/fileB");
        use POSIX;        use File::Copy cp;
        $n=FileHandle->new("/dev/null","r");        cp($n,"x");'
 

DESCRIPTION

The File::Copy module provides two basic functions, copy andmove, which are useful for getting the contents of a file fromone place to another.
The copy function takes twoparameters: a file to copy from and a file to copy to. Eitherargument may be a string, a FileHandle reference or a FileHandleglob. Obviously, if the first argument is a filehandle of somesort, it will be read from, and if it is a file name it willbe opened for reading. Likewise, the second argument will bewritten to (and created if need be).

Note that passing infiles as handles instead of names may lead to loss of informationon some operating systems; it is recommended that you use filenames whenever possible. Files are opened in binary mode whereapplicable. To get a consistent behavour when copying from afilehandle to a file, use binmode on the filehandle.

An optional third parameter can be used to specify the buffersize used for copying. This is the number of bytes from thefirst file, that wil be held in memory at any given time, beforebeing written to the second file. The default buffer size dependsupon the file, but will generally be the whole file (up to 2Mb), or1k 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.

The move function also takes two parameters: the current nameand the intended name of the file to be moved. If the destinationalready exists and is a directory, and the source is not adirectory, then the source file will be renamed into the directoryspecified by the destination.

If possible, move() will simply rename the file. Otherwise, it copiesthe file to the new location and deletes the original. If an error occursduring this copy-and-delete process, you may be left with a (possibly partial)copy of the file under the destination name.

You may use the ``mv'' alias for this function in the same way thatyou may use the ``cp'' alias for copy.

File::Copy also provides the syscopy routine, which copies thefile specified in the first parameter to the file specified in thesecond parameter, preserving OS-specific attributes and filestructure. For Unix systems, this is equivalent to the simplecopy routine. For VMS systems, this calls the rmscopyroutine (see below). For OS/2 systems, this calls the syscopyXSUB directly.

Special behavior if syscopy is defined (VMS and OS/2)

If both arguments to copy are not file handles,then copy will perform a ``system copy'' ofthe input file to a new output file, in order to preserve fileattributes, indexed file structure, etc. The buffer sizeparameter is ignored. If either argument to copy is ahandle to an opened file, then data is copied using Perloperators, and no effort is made to preserve file attributesor record structure.

The system copy routine may also be called directly under VMS and OS/2as File::Copy::syscopy (or under VMS as File::Copy::rmscopy, whichis the routine that does the actual work for syscopy).

rmscopy($from,$to[,$date_flag])
The first and second arguments may be strings, typeglobs, typeglobreferences, or objects inheriting from IO::Handle;they are used in all cases to obtain thefilespec of the input and output files, respectively. Thename and type of the input file are used as defaults for theoutput file, if necessary.

A new version of the output file is always created, whichinherits the structure and RMS attributes of the input file,except for owner and protections (and possibly timestamps;see below). All data from the input file is copied to theoutput file; if either of the first two parameters to rmscopyis a file handle, its position is unchanged. (Note that thismeans a file handle pointing to the output file will beassociated with an old version of that file after rmscopyreturns, not the newly created version.)

The third parameter is an integer flag, which tells rmscopyhow to handle timestamps. If it is < 0, none of the input file'stimestamps are propagated to the output file. If it is > 0, thenit is interpreted as a bitmask: if bit 0 (the LSB) is set, thentimestamps other than the revision date are propagated; if bit 1is set, the revision date is propagated. If the third parameterto rmscopy is 0, then it behaves much like the DCL COPY command:if the name or type of the output file was explicitly specified,then no timestamps are propagated, but if they were taken implicitlyfrom the input filespec, then all timestamps other than therevision date are propagated. If this parameter is not supplied,it defaults to 0.

Like copy, rmscopy returns 1 on success. If an error occurs,it sets $!, deletes the output file, and returns 0.

 

RETURN

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

AUTHOR

File::Copy was written by Aaron Sherman <ajsAATTajs.com> in 1995,and updated by Charles Bailey <baileyAATTgenetics.upenn.edu> in 1996.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN
AUTHOR

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector