next up previous
Next: About this document Up: No Title Previous: No Title

Lab Assignment #3

Due by 10:30 p.m. on Tuesday, February 2.

A. Reading

In the text, read the comments on style on pages 546-550, skipping any that refer to things you haven't had yet. It's time to start keeping style in mind in writing Perl scripts. We don't have to follow the style suggestions religiously, but when we deviate we should have in mind a reason why.

B. Problems to do but not to submit

C. Problems to submit

  1. Write a script make_perl that will help get you going on any Perl project by making a ``skeleton'' script for you to start from. The usage will be

    make_perl scriptname where you can put any name you want for the script name.

    This script should check to make sure there isn't already a file by that name; open a file with the given name, for writing into; put the proper heading information in the file; and make the file executable by you, or if the name ends in .cgi, make the file executable by all.

    To do this, you'll need some Perl commands that will be discussed in section Thursday or lecture Friday, although you could also read up on them earlier: -e, open, print FILEHANDLE, and chmod or `...` or system(...).

  2. If a browser is given a URL that is a directory instead of a file, the browser will look first for a file called index.html and display it if one is found. Make a personal home page by putting a file with that name in your public_html directory and making it readable by all. Its HTML tags should be based on HTML ideas that will be discussed in section and in class. Do what you want with it.

    However, it is not necessarily a good idea to put personal information on the Web. Also, this page will disappear after the end of the course. Therefore if you wish it can be an imaginary web page, with made-up information--but if you do that it might be good to label it as imagined.

    No need to submit this one, since it can be viewed directly.

  3. This problem is the reverse of Problem 2.3.

    A simple database is usually organized into ``records'', each with ``fields''. An example is the roster database used in Problem 2.3, where each record is on one line and the fields are separated by colons. You wrote a script to take the roster database and print it out with each field on a separate line, preceded by a label giving the field name. Records were separated by blank lines.

    We treated this second form as just a report, but it's also a nice way to enter data in the first place, if it's up to you to make the original roster file. The only change you might want to make in the format is that instead of full field names, such as Name: Makam, Huli, you can use something shorter such as N: Makam, Huli . (One letter is enough since in this database the field names each start with a different letter.) Also, it's not necessary to line up the information vertically. After typing the data this way, you can use a Perl script to put the data into the original database form with colon separators.

    Write a script that does this. (As before, ignore the last two fields in the roster file; just don't make them.) In other words, the input to the script should be the same as your output in Problem 2.3 except for using one-letter field names and not lining up vertically; the output should be the same as the input in Problem 2.3 except for omitting the last two fields.

    Some considerations:

    Here just some ingredients have been listed. You should think through the needed logic and plan the program yourself, but you can consult with the TA and instructor as needed.


next up previous
Next: About this document Up: No Title Previous: No Title

Kirby A. Baker
Thu Jan 28 20:36:38 PST 1999