NAME
File::Versions - Emacs-like versioned file names
SYNOPSIS
use FindBin '$Bin';
use File::Versions 'make_backup';
my $backup = make_backup ("$Bin/file");
# If the environment variable 'VERSION_CONTROL' is set to
# 'numbered', 'file' is moved to 'file.~1~'. The value of the new
# file name is put into '$backup'.
VERSION
This documents File::Versions version 0.10 corresponding to git commit e92bce4dbd4380b54aee11a352e18879b0e8c226 released on Sun Feb 14 14:09:19 2021 +0900.
DESCRIPTION
This module duplicates the behaviour of programs like the Emacs text editor under Unix, where the environment variables VERSION_CONTROL
and SIMPLE_VERSION_CONTROL
allow one to make numbered backups of a file.
FUNCTIONS
backup_name
my $backup = backup_name ('file');
Make an appropriate numbered backup name for file. The return value is this name.
make_backup
make_backup ('file');
Make a backup of the file specified by file, by renaming file to its backup name, as given by "backup_name". If such a file already exists, delete it using unlink
before renaming $file
.
This subroutine dies using "croak" in Carp on error. If it succeeds, the return value is the name of the backup file.
SEE ALSO
There is something similar to this module in the source code of the "rename" utility which comes with Perl.
CPAN modules
- File::BackupCopy
-
It is remarkably similar to this module.
EXPORTS
"backup_name" and "make_backup" are exported on demand. The export tag :all
exports everything.
use utf8;
use FindBin '$Bin';
use File::Versions ':all';
DEPENDENCIES
AUTHOR
Ben Bullock, <bkb@cpan.org>
COPYRIGHT & LICENCE
This package and associated files are copyright (C) 2010-2021 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.