--- name: File::Copy runtime: pp source: src/native/File/Copy/pp.rs --- ```{index} single: File::Copy; Perl module (pp runtime) ``` # File::Copy Native implementation of File::Copy 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. ```perl use File::Copy; copy("src.txt", "dst.txt") or die "Copy failed: $!"; copy($fh_in, "dst.txt"); ``` ## move Move a file from source to destination (rename, or copy+unlink if cross-device). Returns 1 on success, 0 on failure. ```perl use File::Copy; move("old.txt", "new.txt") or die "Move failed: $!"; ``` ## cp Alias for copy (available via `use File::Copy 'cp'`). ## mv Alias for move (available via `use File::Copy 'mv'`).