PERL Programming for "experienced" programmers
Spring 2005 - March 28th - April 29th

  1. STUDY GUIDE for the PERL EXAM and a separate Study Guide hints page. Also, here is Questions 33 to 38 answers or hints supplement.
  2. Practice material for the PERL final exam. Old midterm exam from a few years back.

  3. Checkboxes: How to do CHECKBOXES is demonstrated (from the Monday, April 25th class). (Posted 5:45 a.m. Wednesday, April 27th).

    See an online PowerPoint presentation for and several example applications too.

  4. Last PERL assignment (Movies Database) resources links to study.

    The links including class #36 and class #35 are great resources too.

    Download the Movies Database by right-clicking on this link and choosing from popup-menu. Download the movies database in the lab directly to your Z: drive.

  5. Here is the online quiz for you to try out: PERL Online quiz uses your own UNI user id, and the password you chose on April 13th in class. TAKE THE QUIZ SEVERAL TIMES UNTIL YOU GET A PERFECT SCORE.

  6. Assignment One: Write a CGI program using PERL. Your program allows the user to see the calendar for an entire year, for a month, or for a series of months that are within this year, or whatever year is specified.
    Your CGI program will have a SUBMIT button, and two TEXTBOXES, and
    suitable labels and heading and so on so the user enjoys the user
    interface provided, and knows how to use it and what it can do.
                    Month(s) 2,4,8-11 
         The output would be the February, April,
         and the August, September, October and November months
         for the current year, whatever the current year 
         happens to be:  Your CGI program should work as well
         in 2008 as it does in 2005!
                    Year        2006
         Your output would be all 12 months of whatever year
         the user asks for, but it will be just as the Unix
                        cal 2006 
                                   command would output it.
         Your output would be just the current month's calendar.
                  on Unix or Linux with no arguments gives you
                  this months calendar.
              cal 4 2005
              cal                <------ Same output until 5/1/2005 gets here
  7. Be careful about trying to avoid using the Linux or Unix editors, such as pico (or nano). Why? Files from Windows have a different format from files from Unix.
    venkman@bebop:~/web/cgi-bin$ 000calNotepad.cgi 
    : bad interpreter: No such file or directory
    venkman@bebop:~/web/cgi-bin$ 000calAfterPico.cgi      
    : bad interpreter: No such file or directory         <--------- MYSTERY
       pico 000calAfterPico.cgi               <----- open UNIX editor, make any
       000calAfterPico.cgi                           one change, save changes,
                                                     and NOTEPAD windows format
  now...                           chars are GONE.
    venkman@bebop:~/web/cgi-bin$ 000calAfterPico.cgi   <---- FILE converted
    Content-Type: text/html; charset=ISO-8859-1              and extra hidden
                                                             windows chars
                        snipped edit (scissors)              removed, as it
         April 2005                                          was converted
    Su Mo Tu We Th Fr Sa                                     to UNIX (Linux)
                    1  2
     3  4  5  6  7  8  9 server is UNIX (Linux),
    10 11 12 13 14 15 16                                not windows...
    17 18 19 20 21 22 23
    24 25 26 27 28 29 30     
  8. Exam on Friday, April 29th. Last day of PERL class.

  9. 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.

  10. Writing a function that creates Ordered Lists, something like already provides as the ol() function.
  11. 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

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

Example two: Vertical printing CGI program, that does alot more.

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.
(IGNORE for NOW!!!!): Download the files for assignment #1 (OLD NOTE: 2004). 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.