#!/usr/bin/perl -w use strict; system "clear"; print "Palindrome - gamma version\n"; print "--------------------------\n\n"; print "Please enter DNA filename: "; my $filename=; chomp $filename; die "No such file...exiting\n\n" unless (-e $filename); open(DNASEQ, $filename) or die "Cannot open file...exiting\n\n"; my $last_protein; my $count_of_2=0; while () { chomp; my ($lba,$rba)= ($last_protein, undef); for (my $lb = 0; $lb < (length) - 1; ++$lb) { $lba = substr ($_, $lb, 1); $rba = substr ($_, $lb+1, 1); $rba =~ tr/atgcATGC/tacgTACG/; ++$count_of_2 if ($lba eq $rba); } $last_protein = $rba; } print "Number of 2bp palindromes: ", $count_of_2, "\n";