The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Backup::Hanoi - select backup according to algo

VERSION

version 0.004

SYNOPSIS

This is an early release. This code is currently not used in production by the author. Use it with care!

 my @devices = ('A', 'B', 'C', 'D');
 my $backup  = Backup::Hanoi->new(\@devices);

 # calculate the next 100 backup cycles
 for (0 .. 99) {
     print $backup->get_device_for_cycle($_);
     print "\n";
 }
 
 # enhanced compination of FIFO for initialisation
 # and Hanoi algorithm for overwriting
 for (-3 .. 99) {
     print $backup->get_device_for_cycle($_);
     print "\n";
 }

See also the script backup-hanoi.

FUNCTIONS

new

Takes a reference to a list with at least three items.

get_device_for_cycle

Give any integer, receive a string which represents the selected item.

Negative numbers up to zero select devices according to FIFO. Where 0 gives back the last element and (elements -1) the first. This can be used to initialise each empty device.

Positive numbers select according to the algorithm «Tower of Hanoi». This can be used to efficiently choose which device to overwrite.

AUTHOR

Boris Däppen <bdaeppen.perl@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Boris Däppen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.