in reply to Generate Matrix in perl

I'll skip the data reading... With the data in memory, it would go like this:
#!/usr/bin/perl use warnings; use strict; my $src = [['A', 'B', 'C', 'D'],['P', 'Q', 'R'],['1', '2', '3', '4', ' +5']]; my $products = ['']; for my $level (@$src) { my $old_products = $products; $products = []; for my $prefix (@$old_products) { for (@$level) { push(@$products, "$prefix$_"); } } } print "$_\n" for @$products;
Update: That's merely to help your logic. From the practical view, advices from almut and moritz are probably better.

Replies are listed 'Best First'.
Re^2: Generate Matrix in perl
by cs08 (Initiate) on Jul 29, 2008 at 14:16 UTC
    Thanks Guys! I could able to resolve it using Set::CrossProduct Thanks again!