PERL Programming for "experienced" programmers
Spring 2003 - Feb 17th thru March 28th

  1. Exam on Friday, March 28th. Last day of PERL class.

  2. Regular expressions examples from the Civil War battled/fought group exercise problem.

  3. Basis for your Last PERL assignment and resources and links for movies database application for the web. Due date will be Friday, April 4th. This is one week AFTER the PERL class final exam and final class day on Friday, March 28th.

  4. Download the movies database by right-clicking this link or click the link just to look at the database.

  5. Examples of using the sprintf function for formatting numbers and strings, including left justification within a field.

  6. PERL programming assignment two is not a CGI web program. You can run it from the command prompt. It is the program to count the words in a file, that was started as a group exercise on Wednesday or Friday.

  7. Page counters, tracking visitors IP numbers and time of visit and using the PERL localtime() function, as well as the %ENV hash that is provided by CGI automatically.

  8. Try out your the user id and password you were given in class by linking to PW2003.cgi, which is a PERL script that generates two different FORMs. One of them demonstrates the web site that requires a user id and password to access. If you did not get your user id and password, or lost yours, feel free to send email to so I can look it up and send it to you.

  9. Quiz One: Online QUIZ ONE is a set of PERL scripts that presents a quiz and then grades it, gives feedback on which questions you got right and wrong and also sends email to you and the instructor with your results. The feedback page will be different depending on what time of day or night you take the page, so feel free to try it out at different times.

  10. Here is an old PERL class Study Guide and great set of practice questions/exercises to prepare you for the future exam.

  11. Writing a function that creates Ordered Lists, something like already provides as the ol() function.

  12. How do you create a password box using CGI instead of writing the HTML for the FORM element? CGI and Perl.doc links to explore.

Hash counting characters example. The exists function is used to tell whether a key value is already stored in the hash.
Hash of key/value pairs created from comma and semicolon separated values. Nice example for handling letter4.txt data.
$str = "UNI,Panthers;ISU,Cyclones;Iowa,Hawkeyes;USC,Trojans;" .

@schools = split(/;/, $str);
foreach (@schools)
   ($schoolName, $mascot) = split(/,/, $_);
   $schoolHash{ $schoolName } = $mascot;          # $schoolName is the key
}                                                                      ---
perl hashSchools.p      

  Mascot for  Pepperdine is Waves
              UNI is Panthers
              Iowa is Hawkeyes
              ISU is Cyclones
              Idaho is Vandals
              USC is Trojans

PERL class example from Friday, February 28th. The ord and chr functions.

Vertical printing CGI program, including a PERL script to show you the PERL code.

PERL FAQ page especially for UNI and environment.

Study these week 2 resources and and examples. They will help a great deal for the children's book new name game software and CGI application you are creating.

Example of the simplest possible script that submits FORM data to itself. One textbox, one submit button. It is self-referencing.
See an online PowerPoint presentation for and several example applications too.
Download the files for assignment #1. I have renamed them letter2.txt, letter3.txt and letter4.txt. (NOTE: Right-click your mouse to download each of these files to your computer).
  1. letter2.txt used to determine first half of your new last name, from the 2nd letter of your old last name.
  2. letter4.txt used to determine second half of your new last name, from the 4th letter
  3. letter3.txt used to determine your new first name, from the 3rd letter of your old first name.

  4. How the letter4.txt file was created: SPLIT it up and JOIN it back together, with some transliteration beforehand.
    ----------------------------------  Splitting a Value into Pieces page 185.
    ----------------------------------  JOIN is the opposite of SPLIT.
    open (FILE, "letter4Before.txt");
    $letter4Data = "";
                                        Extraction and 
    while ()
    {                                   Report
       chomp $_;
       $_ =~ tr/ >//d;                  Language
       @pair = split /=/, $_;
       $newPair = join (",", @pair);
       $letter4Data .= $newPair . ";";
    chop $letter4Data;
    close FILE;
    open (OUTFILE, ">letter4.txt");
    print OUTFILE "$letter4Data";
    close OUTFILE;

Spell checking and running Unix commands from a PERL script. Also illustrates files and has a link to the trinary conditional operator that was covered on February 24th in class.

Review of class #2, along with suggested readings from textbook.

Prime numbers, Unix cal, etc.. First PERL web page from summer of 2002.

Snowball sentences, chomp, reading input files, etc. Second PERL web page from summer of 2002.

Random quotes, version #1.

Random quotes, version #2.

Random quotes, version #3. This one allows hypenated lists. 1,2-5,8,12 would display quotes 1, 2, 3, 4, 5, 8 and 12, for example.