in reply to Problem while refactoring code into a subroutine (was: subroutines!!!)

Just try $dna->[$i], and in other places in the same way. $dna is a reference - read a bit about references in Perl.