Exercise 5.8 Modify Example 5-3 to not only find motifs by regular expressions b
ID: 669779 • Letter: E
Question
Exercise 5.8
Modify Example 5-3 to not only find motifs by regular expressions but to print out the motif that was found. For example, if you search, using regular expressions, for the motif EE.*EE, your program should print EETVKNDEE. You can use the special variable $&. After a successful pattern match, this special variable is set to hold the pattern that was matched.
Exercise 5.9
Write a program that switches two bases in a DNA string at specified positions. (Hint: you can use the Perl functions substr or slice.
Exercise 5.10
Write a program that writes a temporary file and then deletes it. The unlink function removes a file: just say, for example:
but also check to see if unlink is successful.
(I NEED THE PROGRAMS WRITTEN IN PERL, PLZ HELP ASAP)
Explanation / Answer
use File::Temp qw/ tempfile tempdir /;
$fh = tempfile();
($fh, $filename) = tempfile();
($fh, $filename) = tempfile( $template, DIR => $dir);
($fh, $filename) = tempfile( $template, SUFFIX => '.dat');
($fh, $filename) = tempfile( $template, TMPDIR => 1 );
unlink @tempfile.dat;