G'day supriyoch_2008,

The builtin glob function handles this fine.

#!/usr/bin/env perl use strict; use warnings; use Inline::Files; my @file_data = map { [ do { local $/; <$_> } =~ /(\w+)/gm ] } *K1_TXT, *K2_TXT, + *K3_TXT; my $glob_string = join '' => map { '{' . join(',' => @$_) . '}' } @fil +e_data; print "$_\n" for glob $glob_string; __K1_TXT__ A1T1 A2T3 __K2_TXT__ C1G1 C1G2 C2G1 __K3_TXT__ A1C1

Output:

A1T1C1G1A1C1 A1T1C1G2A1C1 A1T1C2G1A1C1 A2T3C1G1A1C1 A2T3C1G2A1C1 A2T3C2G1A1C1

However, if you want to use File::Glob, this code produces the same output.

#!/usr/bin/env perl use strict; use warnings; use Inline::Files; use File::Glob qw{bsd_glob}; my @file_data = map { [ do { local $/; <$_> } =~ /(\w+)/gm ] } *K1_TXT, *K2_TXT, + *K3_TXT; my $glob_string = join '' => map { '{' . join(',' => @$_) . '}' } @fil +e_data; print "$_\n" for bsd_glob $glob_string; __K1_TXT__ A1T1 A2T3 __K2_TXT__ C1G1 C1G2 C2G1 __K3_TXT__ A1C1

I would recommend you put 'use strict;' at the top of your code and fix all the problems it highlights; including bareword in 'use File::Glob(bsd_glob);' and a plethora of undeclared variables (@array, $combi, $number, and others). I also found your code hard to read; the main problem was indentation — take a look at perlstyle.

-- Ken


In reply to Re: How can one get all possible combinations of elements of different arrays using File::Glob(bsd_glob)? by kcott
in thread How can one get all possible combinations of elements of different arrays using File::Glob(bsd_glob)? by supriyoch_2008

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.