esolm has asked for the wisdom of the Perl Monks concerning the following question:

OK - maybe i'm lame but I haven't found a move function in perl.
Doing a copy is easy with the module File::Copy
Doing a rename is easy with perl's built in fuction rename
But when dealing with large files I would rather move the file rather than use a copy feature.

Any ideas.

Thanks,
Eli

Replies are listed 'Best First'.
Re (tilly) 1: copy, move, rename
by tilly (Archbishop) on Mar 19, 2001 at 23:18 UTC
    File::Copy also has a move function.

    This is better than the built-in rename because it is guaranteed to work across partition boundaries.

Re: copy, move, rename
by knobunc (Pilgrim) on Mar 19, 2001 at 23:18 UTC
    Use File::Copy move. This will do a rename (if the file is on the same filesystem) or actually copy the file bit-for-bit to the target. If the operation fails mid-move you may have a partial copy of the file in the target location.

    On most filesystems rename is the same as move as long as the source and target are on the same filesystems since the name just contains a pointer to the blocks on disk where the contents of the file are. So for intra-filesystem moves renaming /foo/bar/asd to /foo/rab/dsa is the same as copying it.

    Short version: use File::Copy move.

    -ben

Re: copy, move, rename
by arturo (Vicar) on Mar 19, 2001 at 23:11 UTC

    rename will move a file if you give it a different path.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: copy, move, rename
by busunsl (Vicar) on Mar 19, 2001 at 23:13 UTC
    Well, the built-in rename will also move the file.

    But be sure to read the doc.