[an error occurred while processing this directive]

Perl

Menu

In-Class Assignment #5

In this assignment, you will create several subroutines and use references to pass data and create multi-dimensional structures.

Copy or download the file ~lallip/perl/ica5.pl, which contains the framework for your assignment. You must fill in all the code snippets that are marked with numbered comments. You are not permitted to change any other area of the code.

There are 5 numbered comments, and hence five tasks to complete:

  1. Add a new key/value pair to the hash. The value is a reference to an array of numbers.
  2. Call a subroutine with one scalar argument, and store its return value
  3. Call a subroutine with one scalar argument, and an array of values. You may choose wheter to pass that array directly, or to pass a reference to it.
  4. Fill in the first subroutine, taking the single scalar argument, and computing the sum of all numbers in the array referenced in that hash for that argument.
  5. fill in the second subroutine, taking the scalar and array of values. Return an array of numbers. How you define this subroutine will depend on how you decide to call it in #3

For a full 1 bonus point, complete the sixth task as well. Fill in the subroutine which will take one argument, and based on that argument, print out a sorted list of keys and values from the hash.

More details about all of these steps are in the code itself.

Submission Instructions

To submit, log in to solaris.remote.cs.rpi.edu and run ~lallip/public/submit.pl, and follow the prompts. You may submit infinite times, only the last submission is graded. Your final submission is due at 4pm today, Thursday, March 4, 2010

Perl Quotes
Perl Quotes