#!/usr/bin/perl -w

#
# Calculating the reverse complement of a strand of DNA using string
# 
# The DNA
$DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC'; 

print "Here is the starting DNA:\n\n$DNA\n\n";

# Calculate the reverse 
$revcom1 = reverse $DNA;

# Calculate the complement 
$revcom1 =~ tr/ACGTacgt/TGCAtgca/;

print "Here is the reverse complement DNA using STRING:\n\n$revcom1\n\n"; 

#
# Calculating the reverse complement of a strand of DNA using array
# 

# Split the DNA string into an array of characters
@DNA = split('', $DNA);

# Calculate the reverse 
@reverse = reverse @DNA;

# Join the array of characters of the reverse
$revcom2 = join('', @reverse);

# Calculate the complement 
$revcom2 =~ tr/ACGTacgt/TGCAtgca/;

print "Here is the reverse complement DNA using ARRAY:\n\n$revcom2\n"; 