Monday, August 6, 2012

logger functionality to create backup of files

# Function Name : backup_result_file
# Input            : Number of backups, Name of the result file
# Output        : none
# Description    : This function will create backup of result file. Max number of backups handle are passed as first parameter
# Created By    : Rinkesh Bansal
#
sub backup_result_file($$)
{
    my ($num_of_backup, $result_file) = @_;

    for (my $i = $num_of_backup - 2; $i > 0; $i--)
    {
        my $temp = $i + 1;
        my $source = "${result_file}.${i}";
        my $target = "${result_file}.${temp}";
        &copyFile($source, $target);
    }
    my $source = "${result_file}";
    my $target = "${result_file}.1";
    &copyFile($source, $target);
    unlink($source);
}

No comments:

Post a Comment