in reply to Maximum string length

A big problem I see in your program is that you are reading the whole file into an array first and then are assigning that to a scalar so you have TWO copies of the whole file in memory. It would be more memory efficient just to read the file directly into a scalar.
use warnings; use strict; system 'clear'; print "Palindrome - gamma version\n"; print "--------------------------\n\n"; print 'Please enter DNA filename: '; chomp( my $filename = <STDIN> ); open DNASEQ, $filename or die "Cannot open $filename: $!"; ( my $dna = do { local $/; <DNASEQ> } ) =~ tr/atcgATCG//cd; my $count_of_2 = () = $dna =~ /a(?=t)|t(?=a)|c(?=g)|g(?=c)/ig; print "Number of 2bp palindromes: ", $count_of_2, "\n"; __END__
See if that produces the same result as your friend's C++ code.