Learning Perl, ed. 4:
Chapter 4; p. 54-67
Learning Perl, ed. 5:
Chapter 4; p. 55-67
Learning Perl, ed. 6:
Chapter 4; p. 63-71
- Subroutines: a subroutine is both a way of hiding complexity and a way
of reusing code.
- Scope of variables.
Necessary files to complete this exercise
To download the files to your system, just press the Shift key while
you left click on the blue link. Follow the instructions.
All the following exercises have to be done in Perl
- Make a subroutine that take a DNA sequence (string) as
parameter and return the complement strand (reverse complement).
Use it to improve 7.3 which works on dna7.fsa.
- Improve on 2.10 by making a subroutine that calculates the factorial.
Add some input control (make sure you get positive integers, when you
ask for a number).
- Make a subroutine, that returns the relevant one-letter
designation for the correct ammino acid, when you give it a codon (3 bases).
You can find a list here.
If something invalid is given as input to the subroutine, return an error code (make one up).
You can reuse the hash from last lesson for most of the exercise,
if you want.
- Make a subroutine that (only) removes duplicates from a list and returns the
clean list. Use it to improve 6.3.