|
File::Inplace - Perl module for in-place editing of files |
use File::Inplace;
my $editor = new File::Inplace(file => "file.txt");
while (my ($line) = $editor->next_line) {
$editor->replace_line(reverse $line);
}
$editor->commit;
File::Inplace is a perl module intended to ease the common task of editing a file in-place. Inspired by variations of perl's -i option, this module is intended for somewhat more structured and reusable editing than command line perl typically allows. File::Inplace endeavors to guarantee file integrity; that is, either all of the changes made will be saved to the file, or none will. It also offers functionality such as backup creation, automatic field splitting per-line, automatic chomping/unchomping, and aborting edits partially through without affecting the original file.
File::Inplace offers one constructor that accepts a number of parameters, one of which is required.
next_line. Additionally, the contents of $/ will not
be appended when replacing lines.
next_line_split method. If unspecified, then this defaults
to \s+.
separator
specified at construction time.
next_line, except splits based on the regex specified in
the constructor.
Chip Turner, <chipt@cpan.org>
Copyright (C) 2005 by Chip Turner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.0 or, at your option, any later version of Perl 5 you may have available.
|
File::Inplace - Perl module for in-place editing of files |