in reply to Generate Matrix in perl

You could also use glob:

my @set = glob "{A,B,C,D}{P,Q,R}{1,2,3,4,5}"; print "@set\n";

___

$ ./700577.pl AP1 AP2 AP3 AP4 AP5 AQ1 AQ2 AQ3 AQ4 AQ5 AR1 AR2 AR3 AR4 AR5 BP1 BP2 BP +3 BP4 BP5 BQ1 BQ2 BQ3 BQ4 BQ5 BR1 BR2 BR3 BR4 BR5 CP1 CP2 CP3 CP4 CP5 CQ +1 CQ2 CQ3 CQ4 CQ5 CR1 CR2 CR3 CR4 CR5 DP1 DP2 DP3 DP4 DP5 DQ1 DQ2 DQ3 DQ +4 DQ5 DR1 DR2 DR3 DR4 DR5

Replies are listed 'Best First'.
Re^2: Generate Matrix in perl
by linuxer (Curate) on Jul 28, 2008 at 20:36 UTC

    You can even add the comma into the glob, so the result is more like the one requested.

    $ perl -e '$,=$\=$/; print glob( "{A,B},{1,2},z" );' A,1,z A,2,z B,1,z B,2,z $

    Sometimes I wonder, why I usually avoid glob...

    edit: minor code changes