The problem is that you've declared lexical variables with my then use them within subroutines without passing them in explicitly or assigning to them from the return values of your subroutines.

For example:

my $combinations2; # ... sub create_motif2 { #creates every possible 6-mer my $base2 = join ",", qw/a t c g/; my $L2 = 6; my $string2 = "{$base2}" x $L2; my $combinations2 = glob $string2; #print join ":", $combinations2; return join ":", $combinations2; }

The $combinations2 declared within the subroutine is fine. It's actually a really good idea. However, it shadows the $combinations2 declared at the top of your program. That's a problem because you use the outer $combinations2 elsewhere in the program without actually assigning to it anywhere.

You could fix just this one case with:

my $combinations2 = create_motif2();</p> <p>Then pass <c>$combinations2
to the subroutines that need it.

Applying that type of change throughout your program will clear up many similar bugs in waiting. I can't guarantee that will make everything work, but it will help.


In reply to Re: discovering motifs by chromatic
in thread discovering motifs by Anonymous Monk

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.