Exercise 5.10D

From Earlham CS Department
Jump to navigation Jump to search

Return to Week 2
Exercise 5.10 in Beginning Perl for Bioinformatics

#!/usr/bin/perl -w

use strict; 

#Damian Almiron

#Ex5-10 

#Pseudocode:

#Write a program that stores info into a temp file and then deletes it.

#Use program from exercise4-5 to get info for a temp file.

#print the temp file.

#unlink the temp file.  

#From ex4-5

# Write a program to reverse transcribe RNA to DNA 

# The RNA  variable 

my $RNA = 'AUGCAUGCAUGCAUGCAUU'; 

print "This is our original RNA:\n\n”

print “$RNA.\n\n"; 

#Reverse transcription 

my $DNA = $RNA; 

    $DNA =~ s/U/T/g; 

#Print the DNA to the screen 

print "Here is the resulting DNA:\n\n"; 

print "$DNA.\n\n"; 

} 

#Copy results to "tmpfile" – go over this code!!! 

my $outputfile = "tmpfile"; 

unless ( open(tmpfile, ">$outputfile") ) { 

    print "Cannot open file \"$outputfile\" to write to.\n\n";

    exit;

} 

#Print what is in tmpfile

print tmpfile "$count\n"; 

#Close the file.

close (tmpfile); 

#Unlink/delete the file  

unlink "tmpfile"; 

#Make sure file has been deleted. 

unless ( open(tmpfile, ">$outputfile") ) { 

    print "The file \"$outputfile\" does not exist.\n\n";

    exit;

} 

#The End

exit;