Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

file::inplace(3pm) [debian man page]

File::Inplace(3pm)					User Contributed Perl Documentation					File::Inplace(3pm)

NAME
File::Inplace - Perl module for in-place editing of files SYNOPSIS
use File::Inplace; my $editor = new File::Inplace(file => "file.txt"); while (my ($line) = $editor->next_line) { $editor->replace_line(reverse $line); } $editor->commit; DESCRIPTION
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. CONSTRUCTOR
File::Inplace offers one constructor that accepts a number of parameters, one of which is required. File::Inplace->new(file => "filename", ...) file The one required parameter. This is the name of the file to edit. suffix The suffix for backup files. If not specified, no backups are made. chomp If set to zero, then automatic chomping will not be performed. Newlines (actually, the contents of $/) will remain in strings returned from "next_line". Additionally, the contents of $/ will not be appended when replacing lines. regex If specified, then each line will be split by this parameter when using "next_line_split" method. If unspecified, then this defaults to s+. separator The default character used to join each line when replace_line is invoked with a list instead of a single value. Defaults to a single space. INSTANCE METHODS
$editor->next_line () In scalar context, it returns the next line of the input file, or undef if there is no line. In an array context, it returns a single value of the line, or an empty list if there is no line. $editor->replace_line (value) Replaces the current line in the output file with the specified value. If passed a list, then each valie is joined by the "separator" specified at construction time. $editor->next_line_split () Line "next_line", except splits based on the "regex" specified in the constructor. $editor->has_lines () Returns true if the file contains any further lines. $editor->all_lines () Returns an array of all lines in the file being edited. $editor->replace_all_lines (@lines) Replaces all remaining lines in the file with the specified @lines. $editor->commit () Completes the edit operation and saves the changes to the edited file. $editor->rollback () Aborts the edit process. $editor->commit_to_backup () Saves edits to the backup file instead of the original file. AUTHOR
Chip Turner, <chipt@cpan.org> COPYRIGHT AND LICENSE
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. perl v5.14.2 2012-03-06 File::Inplace(3pm)

Check Out this Related Man Page

Perl::Critic::Policy::Editor::RequireEmacsFileVariables(User Contributed Perl DocumentatPerl::Critic::Policy::Editor::RequireEmacsFileVariables(3)

NAME
Perl::Critic::Policy::Editor::RequireEmacsFileVariables - Per-file editor settings. AFFILIATION
This policy is part of Perl::Critic::More, a bleeding edge supplement to Perl::Critic. DESCRIPTION
Many text editors know how to find magic strings in files that indicate settings that work best for that file. For example, the file can indicate that it expects four-character indentation. In emacs, this magic string is called "File Variables". There are two syntaxes: "-*- ... -*-" (single-line) and "Local Variables: ... End:" (multi-line). Both syntaxes allow leading and trailing text on the line. The single-line syntax must be used on the first line of the file to be recognized, or on the second line if the first line is a shebang. The following examples are explicitly allowed by Perl: #!perl -w -*- cperl -*- #!perl -w # -*- cperl -*- #!perl # -*- cperl -*- The multi-line syntax must be used "in the last page" (that is, after the last formfeed) at the end of the file. As of Emacs21, the "end of the file" is hard-coded to be the last 3000 bytes of the file (in the hack-local-variables function in files.el). In this syntax, each line must begin and end with the same prefix/suffix pair. That pair is defined by the text before and after the "Local Variables:" string. SEE ALSO
Perl::Critic::Policy::Editor::RequireViModeline <http://www.gnu.org/software/emacs/manual/html_node/File-Variables.html> In Emacs, you can view the "File Variables" info node by typing: "Help-key", "i", "g", "(emacs)File Variables" (where "Help-key" is often "C-h" or "F1".) Alternatively, you can execute the following elisp: (info "(emacs)File Variables") AUTHOR
Chris Dolan <cdolan@cpan.org> Michael Wolf <MichaelRWolf@att.net> COPYRIGHT
Copyright (c) 2006-2008 Chris Dolan This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.16.3 2014-06-10 Perl::Critic::Policy::Editor::RequireEmacsFileVariables(3)
Man Page