in reply to Multiplexing array of arrays?

Module schmodule, you can do it with just the builtin glob:

$ perl -le 'print join( "\n", glob( "static1,ar{1,2},static2,ar{3,4,5} +" ) )' static1,ar1,static2,ar3 static1,ar1,static2,ar4 static1,ar1,static2,ar5 static1,ar2,static2,ar3 static1,ar2,static2,ar4 static1,ar2,static2,ar5

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Multiplexing array of arrays?
by ikegami (Patriarch) on Feb 02, 2010 at 19:44 UTC

    A more generic solution:

    my @spec = ( 'static1', [ 'ar1', 'ar2' ], 'static2', [ 'ar3', 'ar4', 'ar5' ], ); my $pat = join quotemeta(', '), map { ref($_) ? '{'.join(',', map quotemeta, @$_).'}' : quotemeta($_) } @spec; print "$_\n" for glob($pat);
Re^2: Multiplexing array of arrays?
by biohisham (Priest) on Feb 02, 2010 at 19:26 UTC
    Hey, this is really interesting would you please shed more light on how glob is used this way??

    From what I make, it looks like you are matching but what tricks me is the {} so I can be wrong...


    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.
      glob is a list generator. An entry will be generated for each value of a list in curlies
      $ perl -le'print for glob "{a,b,c}{d,e,f}"' ad ae af bd be bf cd ce cf

      A shell example:

      cp file{,.bk}
      is the same as
      cp file file.bk