In class Programming Exercises: Hashes

  1. Write a program that generates all integers between 1 and 100, then makes a hash that uses the number itself as the key and the number squared as the value. Ask the user to input a number between 1 and 100, and return the square of that number using the hash. Return an error message if the input number isn't an integer between 1 and 100.
  2. Using file re-direction (prog3-2.pl < /home/share/bios646/letters.txt), use a hash to count the number of times each letter appears in the file (1 letter per line) . Print out a summary in alphabetical order.
  3. Write a program that translates a 3 base DNA code into the corresponding amino acid. Use a hash that has the triplet codes as the key and the amino acid ( 3 letter code) as value. Have it return an error message if letters other than A, C, G, or T are used or if the codon does not contain 3 letters.