PPI::Transform - Abstract base class for document transformation classes


PPI::Transform - Abstract base class for document transformation classes


PPI::Transform provides an API for the creation of classes and objects that modify or transform PPI documents.


new [ param1 => $value, param2 => $value ]

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 undef if provided bad constructor params.


The document method should be implemented by each subclass, and takes a single argument of a the PPI::Document manpage 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 document anyway, as a convenience, or undef if an error occurs. By default this error should just be that you passed in something that wasn't a the PPI::Document manpage, but may include additional errors depending on the subclass.


The apply method is used to apply the transform to something. The argument must be a the PPI::Document manpage, 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 $filename [, $output ]

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.


- May need to overload some methods to forcefully prevent Document objects becoming children of another Node.


See the support section in the main module.


Adam Kennedy <adamk@cpan.org>


Copyright 2001 - 2006 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.

 PPI::Transform - Abstract base class for document transformation classes