1PPI::Transform(3)     User Contributed Perl Documentation    PPI::Transform(3)
2
3
4

NAME

6       PPI::Transform - Abstract base class for document transformation
7       classes
8

DESCRIPTION

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

METHODS

14   new
15         my $transform = PPI::Transform->new(
16             param1 => 'value1',
17             param2 => 'value2',
18         );
19
20       The "new" constructor creates a new object for your "PPI::Transform"
21       subclass. A default constructor is provided for you which takes no
22       params and creates a basic, empty, object.
23
24       If you wish to have your transform constructor take params, these must
25       be in the form of a list of key/value pairs.
26
27       Returns a new "PPI::Transform"-compatible object, or returns "undef" on
28       error.
29
30   document
31       The "document" method should be implemented by each subclass, and takes
32       a single argument of a PPI::Document object, modifying it in place as
33       appropriate for the particular transform class.
34
35       That's right, this method will not clone and should not clone the
36       document object. If you do not want the original to be modified, you
37       need to clone it yourself before passing it in.
38
39       Returns the numbers of changes made to the document. If the transform
40       is unable to track the quantity (including the situation where it
41       cannot tell IF it made a change) it should return 1. Returns zero if no
42       changes were made to the document, or "undef" if an error occurs.
43
44       By default this error is likely to only mean that you passed in
45       something that wasn't a PPI::Document, but may include additional
46       errors depending on the subclass.
47
48   apply
49       The "apply" method is used to apply the transform to something. The
50       argument must be a PPI::Document, or something which can be turned into
51       a one and then be written back to again.
52
53       Currently, this list is limited to a "SCALAR" reference, although a
54       handler registration process is available for you to add support for
55       additional types of object should you wish (see the source for this
56       module).
57
58       Returns true if the transform was applied, false if there is an error
59       in the transform process, or may die if there is a critical error in
60       the apply handler.
61
62   file
63         # Read from one file and write to another
64         $transform->file( 'Input.pm' => 'Output.pm' );
65
66         # Change a file in place
67         $transform->file( 'Change.pm' );
68
69       The "file" method modifies a Perl document by filename. If passed a
70       single parameter, it modifies the file in-place. If provided a second
71       parameter, it will attempt to save the modified file to the alternative
72       filename.
73
74       Returns true on success, or "undef" on error.
75

SUPPORT

77       See the support section in the main module.
78

AUTHOR

80       Adam Kennedy <adamk@cpan.org>
81
83       Copyright 2001 - 2011 Adam Kennedy.
84
85       This program is free software; you can redistribute it and/or modify it
86       under the same terms as Perl itself.
87
88       The full text of the license can be found in the LICENSE file included
89       with this module.
90
91
92
93perl v5.16.3                      2011-02-26                 PPI::Transform(3)
Impressum