#!/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__