On Tue, Dec 10, 2002 at 03:38:58PM -0800, Rich Morin wrote:
> On occasion, I have found it useful to cobble up a "little language"
> that allows me to generate a list of items, using a wild-card or some
> other syntax, as:
>
> foo[0-9][0-9] yields foo00, foo01, ...
>
> I'm wondering whether Perl should have a similar capability, using REs.
Dominus has an example of an 'odometer' written using closures. If
you want to specify a simple sequence like this using a regex, then
you need to parse the regex (but in reverse).
Alternatively, you could write a generic odometer generator generator
that takes a series of scalars and lists:
my $generator = make_generator('foo', [0..9], [0..9]);
while ($_ = $generator->()) {
## progressively generate foo00, foo01, ...
}
Z.