in reply to discovering motifs

If you need a fast and memory efficient solution for your problem, I recommend Bio::Grep. Your matching here
foreach $combinations (@motifs){ foreach $sequence(@file) { if($sequence =~/$combinations/){ $counter++; } }
is slow. Really slow.

Disclaimer: Bio::Grep is written by me ;).