NAME

App::SimpleScan::Substitution - simple_scan variable substitution support

SYNOPSIS

use App::SimpleScan::Substitution;
# App::SimpleScan::Substitution->new() will create a new object
# with an empty dictionary: any string passed to it will be returned
# unchanged.
#
# Create a new object using a dictionary

my $engine = App::SimpleScan::Substitution( { defs => \%dictionary } );
my @substituted_strings = $engine->expand($string);

# Swap dictionaries.
$engine->dictionary(\%new_hash);
my @different_strings = $engine->expand($string);

DESCRIPTION

App::SimpleScan::Substitution encapsulates simple_scan's combinatorial substitution algorith in a class. This allows us to isolate it from the rest of simple_scan's code (and potentially reuse it later).

INTERFACE

Class methods

new

Creates a new instance of the substitution engine. If a dictionary is supplied, it is stored to be used during calls to expand().

Instance methods

dictionary()

Replaces the current dictionary with a new one. The dictionary is passed in as a hash reference and stored as such. This means if the dictionary hash is changed externally, then the updates are automatically reflected in the dictionary we'll use.

expand(@strings)

Expands the string (or strings) passed as an argument using the current dictionary.

substitution_value($name, @optional_values)

Setter/getter for dictionary entries. If a list of values is supplied, the substitution value is set. In all cases, the value is returned.

delete_substitution($name)

Deletes the named substitution from the dictionary. No action if the substitution is not found.

DIAGNOSTICS

Argument to new is not a hash ref

The new() argument must be a hash ref, if any argument is supplied at all. This is most commonly caused by supplying 'dictionary => /%some hash' and forgetting to put curly braces around it.

dictionary must be a hash reference

You passed in a value for dictionary that wasn't a hash reference. Did you forget to say \%hash?

find_vars_callback must be a code reference

You passed in a value for find_vars_callback that wasn't a code reference. Did you try to just use a regex without sub{} around it?

CONFIGURATION AND ENVIRONMENT

App::SimpleScan::Substitution requires no configuration files or environment variables.

DEPENDENCIES

None.

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-app-simplescan@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Joe McMahon <mcmahon@yahoo-inc.com >

LICENCE AND COPYRIGHT

Copyright (c) 2005, Joe McMahon <mcmahon@yahoo-inc.com >. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.