UNIX Potluck
Assignment #4
Due February 5th
Basic
- (2 points) Factorial. Write a Perl script that gets an integer (say,
N) from the user (either on command line or after being asked for it)
and returns 1!, 2!, etc. up until N!, each on its own line. Use at
least one Perl subroutine. Remember that 1! = 1, 2! = 2 x 1! (or 2),
3! = 3 x 2! (or 6), etc.
- (2) Sort Some Text. Write a perl script that opens and reads a text
file then sorts it and prints the results to the screen. It would be
nice to implement different types of sorting such as ignoring case
(lower case vs. upper case) or numeric sorting in addition to standard
sorting.
- (2) Deal out cards. This perl script will deal out cards from the
type of file discussed earlier (52 lines, etc.). It will take two
arguments: number of players and how many cards each should get. It
should do error checking on input values! And -- It shouldn't
cheat!
Super User
- (3) Shuffle Cards. using a 52 line input file where each line
represents a playing card. The cards should be "shuffled" adequately
when you're done. The input file will contain entries like:
2 C
K D
A H
8 S
etc. The first character represents one of the cards
(2,3,4,5,6,7,8,9,10,J,Q,K,A) and the second character represents one of
the suits (C,D,H,S). Question: How do you know when the cards are
shuffled adequately???
- (2) Create an HTML Index. Write a Perl script that goes through every
HTML and HTM file in a directory and writes a new file called
Index.html that contains a listing for each HTML file in that
directory. The script will look through each HTML/HTM file looking for
a META tag that looks like this: <META name="index-listing"
content="some descriptive information">
If the file is called gingpoor.html then the output will look like
this:
gingpoor.html Some descriptive information
someotherfile.html Other description
The list of file names should be alphabetized and each filename should
be a link to the actual html file.
Wizard
- (3) Random Sentence Generator. Write a Perl script that writes
a random number of grammatically correct (probably) nonsense
sentences. Green dreams cry furiously, for example.
|