www.perl.com
Perl Programming
Review Question and Programming Exercises
  1. Which perl datatype(s) would you use to store each of the following? Write a short example in which you create, access, and modify the data.
    • The current temperature.
    • Name, ID number, and year of people in the Perl class. Think about how the way that you're accessing the data may affect the type of storage used.
    • The above information, but as someone types it into your program (rather than typing it in when you write the program).
  2. We said that my declares a lexically scoped variable. What does that mean? (Ask the nearest Course VI major if you don't know).
  3. Write a short program to accept three numbers as user input and print the average.
  4. Extend the above to accept an arbitrary quantity of numbers. How many ways could you write this? (I can think of at least 5).
  5. Given an array of numbers, print the list without duplicates in ascending orders.
  6. Given an array of numbers, print only the ones which occur more than once.
  7. Write a program that prints only the lines of its input which contain a certain word. (similar to grep).
  8. Use your favorite spreadsheet program to create a spreadsheet and save it in some text format (tab or comma separated values). Now write a program to print out selected fields of rows that meet some criteria.
  9. Write a recursive version of a program to compute factorials.
  10. Write a program that acts as an alarm clock. It should ask you what time to go home and then prints a message when it's time to go. Some useful info
    • The date command on unix machine will tell you the current time and date. There are other ways to do this in Perl, as well, that you can use if you find them.
    • You may wish to use the sleep procedure, which causes your script to sleep for some number of seconds. This is a useful way to insert a timed delay and also doesn't monopolize CPU time.

http://stuff.mit.edu/iap/perl/