in reply to nested foreach loop, match DNA sequences and calculate score

Do yourself a big favor and use warnings and strict in your code at the beginning of each and every script:
    use warnings;
    use strict;

Using warnings and, in particular, strictures would have alerted you to the misuse of  @$DNAsequence1 and  $base1->[0] et al.