#!perl -w use strict; # Calculating the reverse complement of a strand of DNA # The DNA my $DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC'; print "Starting DNA:\n"; print_dna($DNA); print "Reverse Complement of DNA:\n"; print_dna( revcom($DNA) ); # Successful exit exit(0); # Calculate the reverse complement sub revcom { my $dna = shift; # Make a new copy of the DNA (see why we saved the original?) my $revcom = reverse $dna; # See the text for a discussion of tr/// $revcom =~ tr/ACGTacgt/TGCAtgca/; return $revcom; } # sub to print the DNA onto the screen sub print_dna { my $dna = shift; print $dna,"\n"; }