String::Substitute - generate strings using different combinations of subsitute characters
version 0.007
use String::Substitute qw(get_all_substitutes); my @results = get_all_substitutes( string => 'ABC', substitutions => { A => 'Aa', B => 'Bb', }, ); say for @results;
would print (with nondeterministic order):
ABC aBC AbC abC
As a one-liner it might look like this:
perl -Ilib -MString::Substitute=get_all_substitutes -E 'say for get_all_substitutes(string => "ABC", substitutions => { A => "Aa", B => "Bb" })'
This module is all about generating strings given an initial string and a set of allowed character substitutions.
Return, as a list, all possible strings that can be generated by applying different combinations of substitutions to the string passed as the 'string' argument. See SYNOPSIS for an example.
The order in which the different candidates are returned is not guaranteed.
Takes only keyword arguments:
The string you want to apply the substitutions on.
A HASHREF mapping each substitutable character to a string of different characters that it may be replaced with.
e.g. {A => "Aa", B => "Bb"} means that each occurrence of A will be replaced with an 'A', or an 'a', in the returned substitutions.
If you require assistance, support, or further development of this software, please contact OpusVL using the details below:
Telephone: +44 (0)1788 298 410
Email: community@opusvl.com
Web: http://opusvl.com
Nicholas Booker <nick.booker@opusvl.com>
This software is copyright (c) 2017 by OpusVL - www.opusvl.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install String::Substitute, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Substitute
CPAN shell
perl -MCPAN -e shell install String::Substitute
For more information on module installation, please visit the detailed CPAN module installation guide.