File::Versions - Emacs-like versioned file names
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'.
This documents File::Versions version 0.10 corresponding to git commit e92bce4dbd4380b54aee11a352e18879b0e8c226 released on Sun Feb 14 14:09:19 2021 +0900.
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.
VERSION_CONTROL
SIMPLE_VERSION_CONTROL
my $backup = backup_name ('file');
Make an appropriate numbered backup name for file. The return value is this name.
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.
unlink
$file
This subroutine dies using "croak" in Carp on error. If it succeeds, the return value is the name of the backup file.
There is something similar to this module in the source code of the "rename" utility which comes with Perl.
It is remarkably similar to this module.
"backup_name" and "make_backup" are exported on demand. The export tag :all exports everything.
:all
use utf8; use FindBin '$Bin'; use File::Versions ':all';
Ben Bullock, <bkb@cpan.org>
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.
To install File::Versions, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Versions
CPAN shell
perl -MCPAN -e shell install File::Versions
For more information on module installation, please visit the detailed CPAN module installation guide.