- 1) Can I use the sort function to sort the names and/or
GPA's?
- Yes. The sort funtion is very helpful, and although we haven't
covered it in class, is perfectly acceptable to use. It is also
rather intuitive to use. It can be found in your books in Chapter 29.
- 2) How do I sort a hash by value?
- This is slightly more complicated than sorting by key. For an
example, see the entry on the keys funtion in the book, also in
Chapter 29. It involves using and understanding the comparison
operator we talked about in the 2nd lecture
- 3) Does the student report print out info for all students, or
just one?
- One student. Your program should ask the user for which student
on whom to report.
- 4) Are we Really supposed to be able to do this in 30 lines
of code?
- NO. That comment in last week's class was meant to be a joke. I
apparently gave the wrong inflection when saying that. I'm profusely
sorry for any misperceptions
- 5) After adding/changing a grade, do we have to store the new
information in the database file?
- Yes. The new info must be stored back to the original file. The
next time your program is run, it should read in the new information
- 6) My line for getting user input keeps reading from the file on
the command line! What's going on?
- The angle operator <> has a bit of 'magic' that is sometimes
more trouble than it's worth. If the array @ARGV contains any file
names, <> by itself will attempt to read from those files if
possible. There are two ways around this problem:
- Explicitly read from STDIN, rather than leaving the angle operator blank. ie, change lines like
$input = <>;
to
$input = <STDIN>
- After reading from $ARGV[0], remove this element from the @ARGV array. If @ARGV is empty when you call the empty angle operator, it will read from STDIN as expected