#!/usr/bin/perl -ln
use strict;
use warnings;
sub expand;
sub doit;
print for expand $_;
sub expand {
local $_=shift;
return doit $`, (split /:/, $1), $' if /\{([\w:]+)\}/;
return doit $`, $1 .. $2 , $' if /\[(\w+):(\w+)\]/;
$_;
}
sub doit {
my ($pre,$post)=(shift,pop);
map { my $pre=$pre . $_;
map $pre . $_, expand $post } @_;
}
__END__
Original description:
("specifications" have changed too)
This is another short program that for me is a complete application, and I hope that this time there's not a common utility to do the same...
Basically it expands strings of the form
foo[01:100]bar-{fred:barney:wilma}
to the list
foo01bar-fred
foo02bar-fred
...
foo100bar-fred
foo01bar-barney
...
foo100bar-wilma
More info here!