bmcatt has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, fellow monks,

I'm trying to come up with a clever way to solve the following problem and am convinced that I should be able to do it in one line (or thereabouts), but the gray matter isn't working up to full snuff. What I've got so far is:

my @x = (4, 4, 2); my @y; my $pref = 'XX'; foreach my $chunk (1 .. @x) { my $loc = sprintf("$pref%02d:", $chunk); push @y, map {$loc . $_} ( 1 .. $x[$chunk-1] ); }

That gives me:

@y = qw(XX01:1 XX01:2 XX01:3 XX01:4 XX02:1 XX02:2 XX02:3 XX02:4 XX03:1 XX03:2);

which is the right output, but I feel there should be a better way to achieve the end...