5.6. Exercises

See Appendix A for answers.

  1. Write a program that reads in a string, then prints that string and its mapped value according to the mapping presented in the following table:

    InputOutput
    redapple
    greenleaves
    blueocean
  2. Write a program that reads a series of words with one word per line until end-of-file, then prints a summary of how many times each word was seen. (For extra challenge, sort the words in ascending ASCII order in the output.)

Get Learning Perl, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.