String::Range::Expand - Expand range-like strings
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
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.
my @list = expand_range('...');
This function accept a single string, evaluates expressions in those strings and returns a list with all available 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
my @list = expand_expr('foo-bar[01-03] host[aa-ad,^ab]Z[01-04,^02-03].name');
This runs expand_range against every range-like expression detected in the argument list
expand_range
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 of SSH::Batch
String::Range::Expand
SSH::Batch
Pretty similar, but does not evaluate alphabetical ranges
Like String::Glob::Permute, it does not evaluate alphabetical ranges. But it does provide some additional functionality like setting upper limits and formatting.
String::Glob::Permute
This module does not attempt to limit the number of permutations for an expression.
Please report any bugs or feature requests at https://github.com/mithun/perl-string-range-expand/issues
Mithun Ayachit mithun@cpan.org
mithun@cpan.org
Copyright (c) 2014, 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.
To install String::Range::Expand, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Range::Expand
CPAN shell
perl -MCPAN -e shell install String::Range::Expand
For more information on module installation, please visit the detailed CPAN module installation guide.