NAME

Egg::Plugin::File::Rotate - Plugin that does file rotation.

SYNOPSIS

use Egg qw/ File::Rotate /;


my $file_path= '/path/to/savefile'; 

if ( -e $file_path ) {
   $e->rotate($file_path, stock => 5 );
}
my $fh= FileHandle->new("> $file_path") || return do {
  $e->rotate($file_path, reverse => 1 );
  die $!;
  };

% ls -la /path/to
drwxr-x---  ***  .
drwxr-x---  ***  ..
drw-r--r--  ***  savefile
drw-r--r--  ***  savefile.1

DESCRIPTION

It numbers and the backup is left for the file that already exists.

METHODS

rotate ([FILE_PATH], [OPTION])

It file rotates.

Passing to the object file is specified for FILE_PATH. If the file doesn't exist, undefined is returned without doing anything.

OPTION is HASH.

If reverse of OPTION is undefined, it file usually rotates. At this time, the rotation file of the number specified for stock is left. The file that leaks from the number of stock is annulled. The defaults of the number of stock are 5, and the lowest value is 3.

$e->rotate( '/path/to/save.txt', stock=> 10 );

FILE_PATH is renamed and doesn't exist after it processes it.

When reverse of OPTION is defined, processing opposite to a usual file rotation is done. After usual roteate, this is an option to want to return it.

$e->rotate( ...... );
my $fh= FileHandle->new("/path/to/save.txt") || do {
    $e->rotate( "/path/to/save.txt", reverse=> 1 );
    die $!;
  };

rotate_report

The report of the processing situation of the rotate method is returned.

$e->rotate( ...... );
.......
....
print $e->rotate_report;

SEE ALSO

Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.