Anthony Kilna > File-Copy-Vigilant-v1.2.1 > File::Copy::Vigilant



Annotate this POD


Open  0
View/Report Bugs
Module Version: v1.2.1   Source  


File::Copy::Vigilant - Copy and move files with verification and retries


    use File::Copy::Vigilant;

    copy_vigilant( $source, $destination );
    move_vigilant( $source, $destination );


A module for when your files absolutely, positively have to get there.

By default the copy and move functions will perform MD5 sums on the source and destination file to ensure that the destination file is exactly the same as the source file upon completion. If the copy or move fails for any reason it will attempt 2 retries by default.


copy_vigilant, copy, cp

Copies a file, with post-copy verification and optional retries.

        $source, $destination,
        [ check => (checktype), ]
        [ retires => (number of retries), ]

"checktype" is one of the following:

  md5     - Get the MD5 sum of the source before copying, and compare it to
            the MD5 of the destination after copying (default)
  size    - Get the size of the source before copying, and compare it to the
            size of the destination after copying
  compare - Perform a byte-for-byte comparison of the source and destination
            after copying
  none    - Do not perform a check of the source to the destination

"number of retries" is one of the following:

  0          - No retries are performed
  integer    - The number of retries to perform (if a 1 is passed, then the
               copy will be attempted a maximum of 2 times).  Must be a
               positive, whole number.
  'infinite' - The string 'infinite' (and all other strings for that matter)
               will cause it to retry continuously until success

The default is 2 retries (or three attempts total).

If called in a scalar context, it returns 0 for failure or 1 for success. If called in a list context, the return value is a 1 or 0, followed by a list of error messages.

The 'cp' and 'copy' named versions the function are not exported by default, and you must specify them explicitly to use them:

  use File::Copy::Vigilant qw(cp mv);

  cp( $source, $destination );


  use File::Copy::Vigilant qw(copy move);

  copy( $source, $destination );

move_vigilant, move, mv

The syntax and behavior is exactly the same as copy_vigilant, except it perfoms an unlink as the last step.

This is terribly inefficient compared to File::Copy's move, which in most cases is a simple filesystem rename.

'move' and 'mv' are not imported by default, you'll have to add them in the use syntax (see copy_vigilant for details).


Anthony Kilna, <anthony at> -


Please report any bugs or feature requests to bug-file-copy-vigilant at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc File::Copy::Vigilant

You can also look for information at:


File::Copy - File::Copy::Reliable


Copyright 2012 Kilna Companies.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: