Computer Science @ Marlboro  

Web Programming with Perl

Info | Syllabus | Assignments | Lecture Notes | Resources | Roster

Info
 
WhenTuesday/Friday 10:00-11:20am
WhereSci 217
FacultyJim Mahoney (mahoney@marlboro.edu)
Credits 3-4 ( i.e. 9-12 hours/week including class )
Level Intermediate
Prereq some experience with web pages, programming, and the command line
Textbook CGI Programming with Perl, 2nd edition, Guelich, Gundavaram, and Birznieks
Website

As you may have heard, the internet is quite popular these days. Much of the content you find on the WWW - text, forms, images, or whatever - is created and managed by computer programs. In this class you'll learn how to write those programs, and along the way look at various internet technologies.

In addition to learning some Perl (one of the popular languages for doing internet work), we'll also look at how web servers and clients work and how to write programs that create "dynamic content" for the internet. Our web servers run on unix boxes, so you can expect to learn some a bit about unix systems as well. The details of how much we cover and what depth will depend largely on the background skills of those who take the course.

To take this course you should have some experience creating web pages with HTML, as well as some previous programming experience.

You can take this course for either 3 or 4 credits, depending on your background, skills, and how much time you want to put in; basically the 4th credit requires a more thorough approach to the weekly assignments, a mid-term project, and a much more substantial term project, totaling an extra 40 hours of work over the semester.

Expect this webpage to continue to change throughout the semester as assignments and resources are added.


Tentative Syllabus

        Tues/Thur week      topic
 ------------------------------------------------------------------------------
 Sep        3     1   intro - editing files, finding perl, and the command line
       7,   9     2   "hello world"  chap 1       Beginning Perl
      14,  16     3   $x, if         chap 2 & 4   Beginning Perl
      21,  23     4   HTML, HTTP     chap 1 & 2   CGI Programming
      28,  30     5   first CGI      chap 3       CGI Programming
 Oct   5,   7     6   @array, %hash  chap 3       Beginning Perl   mid-term grades
      12,  14     7   sub{}          chap 8       Beginning Perl
           21,    8   HTML forms     online                        Hendrick's days
      26,  28     9   url?foo=bar    chap 4       CGI Programming
  Nov  2,   4    10   use Foo;       
       9,  11    11   CGI.pm
      16,  18    12   files/cookies  chap 10 & 11 CGI Programming
      23              practice                                     Thanksgiving
      29,   2    13   GD.pm graphics chap 13      CGI Programming
 Dec   7         14   projects


Assignments
  1. for Tues September 7
    1. Send me (mahoney@marlboro.edu) an email telling me you're registering for this class.
    2. Read chapter 1 of Beginning Perl.
    3. Browse notes & resources from last year's Perl course here.
    4. Try to run a "hello world" perl program on either (a) your own computer, (b) a lab computer, or (c) a remote shell on akbar.marlboroe.edu or cs.marlboro.edu. Report on your experience in class on Tuesday.
  2. for Tues September 14
    1. Visit and browse around at perlmonks.org.
    2. Visit and browse around at perldoc.com, especially the "perlintro" and "perlfaq" parts of the "Perl Manpage".
    3. Type "perldoc perldoc" at a command prompt. Read what it says, and browse around.
    4. Start reading chapters 1, 2, 3, 4, 8, 9 in Beginning Perl, which cover scalars, lists, loops, and subroutines. (You can of course print this stuff out if you don't like reading from a screen.) Or read similar material from another text. Try some of the exercises at the end of the chapters to practice.
    5. Write a perl program that finds and prints all the prime numbers from 1 to 200.
    6. Send me an email (mahoney@marlboro.edu) with your work.
    7. Alternative 1 : For those with perl experience, read about object oriented programming, either in the tutorials at perlmonks, or in the perlboot, perltoot, perltooc, perlbot tutorials in the man pages at perldoc.com, among other places. Work through some of the examples, and send me a description of what you did.
    8. Alternative 2 : Or, install and compile the apache web server in your cs.marlboro.edu directory. There's plenty of documentation at apache.org. I'd suggest version 1.31, although 2.0.50 is OK, too. After installing, you edit httpd.conf to configure the server, and then run it on a high port like 8123 or whatever you like. (Only the root user can run services on low ports.) Point a browser at http://cs.marlboro.edu:8133/ and see what you get.
  3. for Tues September 21
    1. Write a program that counts how many times each word appears in a large-ish text file. Hint: use a hash for each word.
    2. Write a program that implements the game "hangman", with the user doing the guessing, picking a random work from the /usr/share/dict/words dictionary or other substantial word list of your choice. Details of the user interface are up to you. Be clear about what testing you've done, and put in reasonable documentation.
    3. Time to start talking about CGI. Read chapters 1 and 2 in CGI Programming in Perl, and start reading chapter 12 in Beginning Perl. We'll be talking about the forms and the ENV hash next week, so please try to figure out how that stuff works.
    4. In your html/cgi/ directory on cs.marlboro.edu, create a perl script random_picture.cgi which displays an HTML page with a embedded image chosen at random from several in that directory. We'll discuss how scripts like this get called over the web in class.
  4. for Tues September 28
    1. finish reading 4 in CGI programming; start reading 5
    2. finish reading chapter 12 in Beginning Perl
    3. Write two versions of a "guestbook" application, one using the CGI.pm module and one with just the "bare" %ENV hash. The web script should allow visitors to record a brief message which will be added to a "web log", which you save in some sort of file and display on the page. Depending on how comfortable you are with all this, you are encouraged to explore the use a cookie to remember the user's name, and put up a personalized greeting when they come back.
  5. for Tues October 5
    1. Read chapter 8 in CGI Programming, on Security
    2. Read the WWW Security FAQ
    3. Investigate security flaws in the "guestbook" program. What can it do that it shouldn't? Are there things that would make it even more problematic?
    4. Add the ability to send email to your guestbook program. Turn on "Taint" mode in your guestbook program, and make sure you do this in a secure way.
  6. for Tues October 12
    1. Read the article Preventing Cross-site scripting attacks
    2. . (This is a follow-up to last week's material.) -->
    3. Read chapter 6 in CGI Programming, on templates.
    4. Browse Template Toolkit at .
    5. Check out HTML::Mason, at www.masonhq.com
    6. Work through Jim's examples in code/template/
    7. Pick either Template Toolkit or HTML::Mason (or both) to look at in more detail. Work through some of the examples in their documentation, and start to set up a collection of web pages with a common header/footer theme using the template ideas. If you want to use HTML::Mason you'll have to talk to me about turning it on in httpd.conf, so check with me first.

      I've decided to give two weeks for you to look at templates - there's a lot of stuff here. This means though that you should have something substantial complete by then.

  7. for Tues October 26
    1. See lecture_notes/oct21.txt for sources and details.
    2. Read a bunch of stuff about SQL
    3. Draw an ERD for a smallish registrar database which contains at least this info. Feel free to add other details if you wish.
       student        course        faculty
       -------        ------        -------
       Joe Fish       calculus      Dr. Who
       Joe Fish       physics       A. Einstein
       Mary Green     calculus      Dr. Who
       Mary Green     chemistry     A. Noble
       Ellen White    radio         Dr. Who
       Francis Eld    radio         Dr. Who
       Frank Micklin  chemistry     A. Noble
      
    4. Write a file of MySQL commands that will
      i) create the tables for this database, and
      ii) populate the tables with this data.
    5. Now generate some SQL queries that will find out
      i) which students are taking physics?
      ii) which courses are Dr. Who teaching?
    6. Try some of the "Assessment" exercises on http://sqlzoo.net/
  8. for Tues November 2
    1. Check out my answers to the last assignment in code/registrar_db/v1_sql/, including how to run the mysql stuff and the Perl/DBI version
    2. Read about the Perl/DBI :
    3. Review perl objects - see the perlmonk or perldoc tutorials.
  9. for Tues November 9
    1. Check out my latest addition to this application we're building in code/registrar_db/v2_perlDBI/
    2. Complete the rest of the work that I haven't finished in v2_perlDBI, or do something similar with a database of your own.
    3. Read about Class::DBI; follow the links at http://www.class-dbi.com (start with the BeginnersGuide).
  10. for Tuesday November 16
    1. one of the crypto assignments; see the lecture notes
    2. project proposal
    3. catch up on any outstanding assignments and your webpage of links to 'em
  11. for Tuesday November 30 - optional
    1. last weekly assignment. See the Nov 23 lecture notes. Do either one of these :
      • Use GD to generate a dynamic picture, or
      • Use LWP::Simple and/or HTML::SimpleLinkExtor to fetch and manipulate web pages
    2. Continue work on your projects

Lecture Notes

Resources

Jim Mahoney (mahoney@marlboro.edu)
Last modified <% &lastmodified %>