List::Filter::Transform - lists of find-and-replace operations


List-Filter documentation  | view source Contained in the List-Filter distribution.

Index


NAME

Top

List::Filter::Transform - lists of find-and-replace operations

SYNOPSIS

Top

   use List::Filter::Transform;

   @terms = ( [ 'subroutine', 'gi', 'method' ],
              { 'field',      'gi', 'attribute' ],
              { 'functional', 'gi', 'not broken' ],
             );

   my $filter = List::Filter::Transform->new(
     { name         => 'oop_up_docs',
       terms        => \@terms ,
       description  =>
          "Hunt and destroy passe jargon in docs for spiffy OOP code.",
       modifiers    => "gi",  # redundant with settings in @terms
     } );  # Letting method default to 'sequential'







   # If non-standard behavior is desired in locating the methods via plugins
   my $filter = List::Filter::Transform->new(
     { name              => 'oop_up_docs',
       terms             => \@terms ,
       description       =>
          "Hunt and destroy passe jargon in docs for spiffy OOP code.",
       modifiers         => "g",
       method            => "reverse",
       plugin_root       => "List::Filter::Transform::Internal",
       plugin_exceptions => ["List::Filter::Transforms::NotThisOne"],

     } );

   # alternately
   my $filter = List::Filter::Transform->new();  # creates an empty filter

   my @terms = [ [ 'find_me', 'i', 'replace_with_this' ],
                 [ 'function', '', 'method' ],
                 [ 'variable', '', 'attribute' ],
                 [ 'Function', '', 'Method' ],
                 [ 'Variable', '', 'Attribute' ],
               ];
   $filter->set_name('oop_up_docs');
   $filter->set_terms( \@terms );
   $filter->set_method('sequential');  # typical
   $filter->set_description(
             "Hunt and destroy passe jargon in docs for spiffy OOP code.");
   $filter->set_modifiers( "g" ); # 'g' applied, uh, 'globally'







DESCRIPTION

Top

A "transform" is like a List::Filter "filter" (List::Filter), except that each pattern has an associated replacement expression. A "transform" is essentially a list of perl substitutions ("s///").

At the core of a transform object is the "terms" attribute, an array of arrays of three values:

(1) a perl regular expression, (2) external match modifiers (e.g. 'g'), (3) the replacement expression to substitute for a match

Note: future versions of this code may have support for (4) (optional) a hashref of miscellanious transform attributes.

As with "filters", each transform has a "method" field which specifies how the transform will be used by default. It is expected that applying the substitutions in sequence will be used so frequently, that the default method itself defaults to "sequential".

Valid methods are defined in the List::Filter::Transforms::* modules, by default. And alternate location can be selected with the "plugins_tree" argument, and plugin modules in the tree can be selectively ignored if named in the "plugin_exceptions" array.

As of this writing, the only standard supported transform method is "sequential".

METHODS

new

Instantiates a new List::Filter::Transform object. Inherits from List::Filter.

init

Initialize object attributes and then lock them down to prevent accidental creation of new ones.

basic setters and getters

Note: these accessors are all inherited from List::Filter

name

Getter for object attribute name

set_name

Setter for object attribute set_name

method

Getter for object attribute method

set_method

Setter for object attribute set_method

description

Getter for object attribute description

set_description

Setter for object attribute set_description

terms

Getter for object attribute terms

set_terms

Setter for object attribute set_terms

modifiers

Getter for object attribute modifiers

set_modifiers

Setter for object attribute set_modifiers

dispatcher

Getter for object attribute dispatcher

set_dispatcher

Setter for object attribute set_dispatcher

SEE ALSO

Top

List::Filter List::Filter::Project

AUTHOR

Top

Joseph Brenner, <doom@kzsu.stanford.edu>

COPYRIGHT AND LICENSE

Top

BUGS

Top

None reported... yet.


List-Filter documentation  | view source Contained in the List-Filter distribution.