Otherwise, it copies the file to the new location and deletes the original. If an error occurs during 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 that you may use the cp alias for copy. File::Copy also provides the syscopy routine, which copies the file specified in the first parameter to the file specified in the second parameter, preserving OS-specific attributes and file structure. For Unix systems, this is equivalent to the simple copy routine, which doesn't preserve OS-specific attributes.
For VMS systems, this calls the rmscopy routine see below. For Win32 systems, this calls WinCopyFile. If both arguments to copy are not file handles, then copy will perform a "system copy" of the input file to a new output file, in order to preserve file attributes, indexed file structure, etc.
The buffer size parameter is ignored. If either argument to copy is a handle to an opened file, then data is copied using Perl operators, and no effort is made to preserve file attributes or record structure. The first and second arguments may be strings, typeglobs, typeglob references, or objects inheriting from IO::Handle; they are used in all cases to obtain the filespec of the input and output files, respectively.
The name and type of the input file are used as defaults for the output file, if necessary. A new version of the output file is always created, which inherits 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 the output file; if either of the first two parameters to rmscopy is a file handle, its position is unchanged. Note that this means a file handle pointing to the output file will be associated with an old version of that file after rmscopy returns, not the newly created version.
It is similar to the rm command in Unix or the del command in Windows. For full documentation see perldoc -f unlink. The standard way to copy a file is to use the copy function of File::Copy.
For documentation visit perldoc File::Copy. Toggle navigation Perl Maven. Standard output, standard error and command line redirection Warning when something goes wrong What does die do? Unknown warnings category Can't use string Symbolic references in Perl Can't locate For Win32 systems, this calls WinCopyFile.
If both arguments to copy are not file handles, then copy will perform a "system copy" of the input file to a new output file, in order to preserve file attributes, indexed file structure, etc. The buffer size parameter is ignored. If either argument to copy is a handle to an opened file, then data is copied using Perl operators, and no effort is made to preserve file attributes or record structure.
The first and second arguments may be strings, typeglobs, typeglob references, or objects inheriting from IO::Handle; they are used in all cases to obtain the filespec of the input and output files, respectively. The name and type of the input file are used as defaults for the output file, if necessary.
A new version of the output file is always created, which inherits 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 the output file; if either of the first two parameters to rmscopy is a file handle, its position is unchanged. Note that this means a file handle pointing to the output file will be associated with an old version of that file after rmscopy returns, not the newly created version.
The third parameter is an integer flag, which tells rmscopy how to handle timestamps. If the third parameter to 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 implicitly from the input filespec, then all timestamps other than the revision date are propagated. If this parameter is not supplied, it defaults to 0.
Like copy , rmscopy returns 1 on success. Before calling copy or move on a filehandle, the caller should close or flush the file to avoid writes being lost.
Note that this is the case even for move , because it may actually copy the file, depending on the OS-specific implementation, and the underlying filesystem s.
0コメント