File::Copy
Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.
Provides file copy and move operations.
Perl’s File::Copy supports passing open filehandles as either the source or destination argument. When a filehandle is given as destination, bytes are written to the already-open handle rather than treating the stringified handle id as a filename. Similarly, a filehandle as source is read from the open handle rather than opening a file whose name is the numeric id.
Synopsis
use File::Copy;
copy("source.txt", "dest.txt") or die "Copy failed: $!";
move("old.txt", "new.txt") or die "Move failed: $!";
use File::Copy qw(cp mv);
cp("src", "dst") or die "cp failed: $!";
mv("old", "new") or die "mv failed: $!";
Functions
copy
Copy a file from source to destination. Returns 1 on success, 0 on failure. Accepts filenames or open filehandles for either argument.
use File::Copy;
copy("src.txt", "dst.txt") or die "Copy failed: $!";
copy($fh_in, "dst.txt");
cp
Alias for copy (available via use File::Copy 'cp').
move
Move a file from source to destination (rename, or copy+unlink if cross-device). Returns 1 on success, 0 on failure.
use File::Copy;
move("old.txt", "new.txt") or die "Move failed: $!";
mv
Alias for move (available via use File::Copy 'mv').