http://www.perlmonks.org?node_id=951584


in reply to Seeking help from Perl Monks for counting regular expressions (motifs) and counting lengths between them in a large string

Try to fix the warnings first. Change:
until (my $motif =~ /^\s*$/ );# Line 58
to:
until ($motif =~ /^\s*$/ );# Line 58

Other advice: