Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ppi::transform(3) [mojave man page]

PPI::Transform(3)					User Contributed Perl Documentation					 PPI::Transform(3)

NAME
PPI::Transform - Abstract base class for document transformation classes DESCRIPTION
"PPI::Transform" provides an API for the creation of classes and objects that modify or transform PPI documents. METHODS
new my $transform = PPI::Transform->new( param1 => 'value1', param2 => 'value2', ); The "new" constructor creates a new object for your "PPI::Transform" subclass. A default constructor is provided for you which takes no params and creates a basic, empty, object. If you wish to have your transform constructor take params, these must be in the form of a list of key/value pairs. Returns a new "PPI::Transform"-compatible object, or returns "undef" on error. document The "document" method should be implemented by each subclass, and takes a single argument of a PPI::Document object, modifying it in place as appropriate for the particular transform class. That's right, this method will not clone and should not clone the document object. If you do not want the original to be modified, you need to clone it yourself before passing it in. Returns the numbers of changes made to the document. If the transform is unable to track the quantity (including the situation where it cannot tell IF it made a change) it should return 1. Returns zero if no changes were made to the document, or "undef" if an error occurs. By default this error is likely to only mean that you passed in something that wasn't a PPI::Document, but may include additional errors depending on the subclass. apply The "apply" method is used to apply the transform to something. The argument must be a PPI::Document, or something which can be turned into a one and then be written back to again. Currently, this list is limited to a "SCALAR" reference, although a handler registration process is available for you to add support for additional types of object should you wish (see the source for this module). Returns true if the transform was applied, false if there is an error in the transform process, or may die if there is a critical error in the apply handler. file # Read from one file and write to another $transform->file( 'Input.pm' => 'Output.pm' ); # Change a file in place $transform->file( 'Change.pm' ); The "file" method modifies a Perl document by filename. If passed a single parameter, it modifies the file in-place. If provided a second parameter, it will attempt to save the modified file to the alternative filename. Returns true on success, or "undef" on error. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2011-02-25 PPI::Transform(3)

Check Out this Related Man Page

PPI::Document::File(3)					User Contributed Perl Documentation				    PPI::Document::File(3)

NAME
PPI::Document::File - A Perl Document located in a specific file DESCRIPTION
WARNING: This class is experimental, and may change without notice PPI::Document::File provides a PPI::Document subclass that represents a Perl document stored in a specific named file. METHODS
new my $file = PPI::Document::File->new( 'Module.pm' ); The "new" constructor works the same as for the regular one, except that the only params allowed is a file name. You cannot create an "anonymous" PPI::Document::File object, not can you create an empty one. Returns a new PPI::Document::File object, or "undef" on error. filename The "filename" accessor returns the name of the file in which the document is stored. save # Save to the file we were loaded from $file->save; # Save a copy to somewhere else $file->save( 'Module2.pm' ); The "save" method works similarly to the one in the parent PPI::Document class, saving a copy of the document to a file. The difference with this subclass is that if "save" is not passed any filename, it will save it back to the file it was loaded from. Note: When saving to a different file, it is considered to be saving a copy and so the value returned by the "filename" accessor will stay the same, and not change to the new filename. TO DO
- May need to overload some methods to forcefully prevent Document objects becoming children of another Node. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.2 2011-02-25 PPI::Document::File(3)
Man Page