NAME
String::Range::Expand - Expand range-like strings
SYNOPSIS
use String::Range::Expand;
print "$_\n" for expand_range('host[aa-ac,^ab,ae][01-04,^02-03]');
# Prints ...
# hostaa01
# hostaa04
# hostac01
# hostac04
# hostae01
# hostae04
DESCRIPTION
This module provides functions to expand a string that contains range-like expressions. This is something that is usually useful when working with hostnames, but can be used elsewhere too.
FUNCTIONS
expand_range($string)
my @list = expand_range('...');
This function accept a single string, evaluates expressions in those strings and returns a list with all avaialble permutations. Ranges with limits are expanded using the Range Operator.
my @list = expand_range('[aa-ad]'); # This is identical to ('aa' .. 'ad')
The following formats are recognized and evaluated
my @list = expand_range('foo[bar,baz]'); # Comma separated list
my @list = expand_range('foo[aa-ad,^ab]'); # Negated element
my @list = expand_range('foo[aa-ag,^ab-ad]'); # Negated range
SEE ALSO
- SSH::Batch
-
This is an extremely useful distribution if you are working with hostnames.
String::Range::Expand
was inspired by this distribution, and provides only a subset of features ofSSH::Batch
- String::Glob::Permute
-
Pretty similar, but does not evaluate alphabetical ranges
- Text::Glob::Expand
-
Like
String::Glob::Permute
, it does not evaluate alphabetical ranges. But it does provide some additional functionality like setting upper limits and formatting.
BUGS AND LIMITATIONS
This module does not attempt to limit the number of permutations for an expression.
Please report any bugs or feature requests to bug-string-range-expand@rt.cpan.org
, or through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=String-Range-Expand
AUTHOR
Mithun Ayachit mithun@cpan.org
LICENSE AND COPYRIGHT
Copyright (c) 2012, Mithun Ayachit. 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.