CS552 Assignment 3 (warming up)

This assignment looks big, but it's actually not so bad. You'll just be building stuff up piece-by-piece. You'll probably want the lecture notes for this if you've never used Perl before.

1. Write a perl script that prints this to the standard output:
26 27 28 29 30 
31 32 33 34 35 
36 37 38 39 40 
41 42 43 44 45 
46 47 48 49 50 
Important note: If you write this program:
#!/usr/bin/perl
print <<"DONE";
26 27 28 29 30 
31 32 33 34 35 
36 37 38 39 40 
41 42 43 44 45 
46 47 48 49 50 
DONE
I'll have to drag you out and shoot you.

Hint: You'll want to print a linebreak (\n) when the number is divisible by 5. The remainder operator in Perl is %. So ($number % 5) is zero when $number is divisible by five.

2. Write a Perl script that takes /usr/dict/words and prints out all words there that have an "n" as the second letter. Hint: The regular expression pattern for the beginning of line is ^ and . matches any character.

3. Take the program from part 2 and hack it to replace all of "e"s with "3"s and "t"s with "+"s. So "anteater" becomes "an+3a+3r".

4. Try not to admonish yourself for having done such a silly thing.

5. Modify your script from part 3 to create HTML instead of plain text. Put it up on your web site somewhere.

6. Modify your script from part 1 to create HTML instead of plain text. Arrange the numbers in a table. Put it on your web site somewhere.

7. Modify the script to add anchor tags to each number in the table. The href attribute should be href="number.cgi?num=number", where number is the current number. So the end result for the number 43 would be:

<a href="number.cgi?num=43">43</a>

8. Enable CGI scripts on your web server.

9. Write number.cgi. This CGI script should, along with some kind of snotty and obnoxious prelude, echo the number back at you. Factor the number if you want to. However, if the number is not between 26 and 50, the script should give a rude error message instead.

10. Send email to cs552-handin@cs.uchicago.edu telling us where to find your scripts, both on your web site and in your directory.