{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}
{\f29\fswiss\fcharset128\fprq2{\*\panose 020b0604020202020204}Arial Unicode MS;}{\f30\fswiss\fcharset128\fprq2 @Arial Unicode MS;}{\f101\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}
{\f102\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f104\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}{\f105\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}
{\f106\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f107\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}{\f108\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}
{\f117\fmodern\fcharset238\fprq1 Courier New CE;}{\f118\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f120\fmodern\fcharset161\fprq1 Courier New Greek;}{\f121\fmodern\fcharset162\fprq1 Courier New Tur;}
{\f122\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f123\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f124\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f335\fswiss\fcharset0\fprq2 Arial Unicode MS Western;}
{\f333\fswiss\fcharset238\fprq2 Arial Unicode MS CE;}{\f334\fswiss\fcharset204\fprq2 Arial Unicode MS Cyr;}{\f336\fswiss\fcharset161\fprq2 Arial Unicode MS Greek;}{\f337\fswiss\fcharset162\fprq2 Arial Unicode MS Tur;}
{\f338\fswiss\fcharset177\fprq2 Arial Unicode MS (Hebrew);}{\f339\fswiss\fcharset178\fprq2 Arial Unicode MS (Arabic);}{\f340\fswiss\fcharset186\fprq2 Arial Unicode MS Baltic;}{\f343\fswiss\fcharset0\fprq2 @Arial Unicode MS Western;}
{\f341\fswiss\fcharset238\fprq2 @Arial Unicode MS CE;}{\f342\fswiss\fcharset204\fprq2 @Arial Unicode MS Cyr;}{\f344\fswiss\fcharset161\fprq2 @Arial Unicode MS Greek;}{\f345\fswiss\fcharset162\fprq2 @Arial Unicode MS Tur;}
{\f346\fswiss\fcharset177\fprq2 @Arial Unicode MS (Hebrew);}{\f347\fswiss\fcharset178\fprq2 @Arial Unicode MS (Arabic);}{\f348\fswiss\fcharset186\fprq2 @Arial Unicode MS Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;
\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;
\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}{
\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext15 Default;}{\s16\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext16 header;}{\*\cs17 \additive \fs24\cf1\lang0\langfe255\langfenp255 Numbering Symbols;}}{\info{\title CIS 480 - Perl in Depth - Fall 2004}{\author Sharon Tuttle}{\operator CNRS}
{\creatim\yr2004\mo11\dy4\hr10\min28}{\revtim\yr2004\mo11\dy4\hr10\min39}{\printim\yr2004\mo9\dy9\hr10\min40}{\version3}{\edmins8}{\nofpages4}{\nofwords1141}{\nofchars6507}{\*\company CNRS-HSU}{\nofcharsws7991}{\vern8269}}\margt2079 
\deftab1250\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale90\nolnhtadjtbl \fet0\sectd 
\sbknone\linex0\headery1440\sectdefaultcl {\header \pard\plain \s16\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\fs16 
CIS 480 -  Homework #9 and Week 11 Lab Exercise \tab \tab p. }{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 2}}}{
\par }{\fs16 Fall 2004
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\b\fs22 CIS 480 - Perl in Depth - Fall 2004
\par WEEK 11 LAB EXERCISE and Homework #9
\par 
\par Week 11 lab exercise due: Thursday,  November 4th, END of lab
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 HW #9 due: Thursday, November 11th, 12:00 noon
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b\fs22 ---------------------------------------------------------------------------------------------------------
\par }{\fs22 For EACH of the scripts below (lab exercise AND homework), you are }{\b\fs22 required}{\fs22  to begin EACH with the following:
\par }{\b\fs20 
\par }{\b\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 #!/usr/bin/perl -w
\par \hich\af0\dbch\af0\loch\f2 ###480-author: }{\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 yourLastName}{\b\fs20\loch\af2 
\par \hich\af0\dbch\af0\loch\f2 ###480-scriptname:}{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2  }{\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 yourScriptName}{\b\fs20\loch\af2 
\par }{\b\i\fs20\loch\af2 
\par }{\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 (}{\i\fs28\loch\af2 \hich\af0\dbch\af0\loch\f2 THEN}{\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2  an }{\i\fs20\ul\loch\af2 \hich\af0\dbch\af0\loch\f2 opening comment block }{\i\fs20\loch\af2 
\hich\af0\dbch\af0\loch\f2 containing the NAME of the script file, your name, the date, and a brief description of the purpose of this script)
\par 
\par }{\fs22 Note that the spacing and header need to be exact --- I have developed preliminary Perl scripts to process these in some interesting and useful fashion. 
\par }{\b\fs22 --------------------------------------------------------------------------------------------------------
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\ul WEEK 10 LAB EXERCISE
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 1.\tab Note: }{here is an example of a CGI.pm function that prints a collection of radio buttons:}{\b 
\par }{\b\fs20\loch\af2 
\par }{\tab }{\f2\fs20 radio_group(-name=>'choose_name', 
\par }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2                 -values=>['button1_choice', 'button2_choice'], 
\par \hich\af0\dbch\af0\loch\f2                 -default=>'button2_cho\hich\af0\dbch\af0\loch\f2 ice', 
\par \hich\af0\dbch\af0\loch\f2                 -linebreak=>'true', 
\par \hich\af0\dbch\af0\loch\f2                 -labels=>\\%button_labels, 
\par \hich\af0\dbch\af0\loch\f2                 )
\par 
\par }{\fs22 \tab }{A few notes:
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab I had to put [ ] around the}{\fs22  }{\f2\fs20 -values}{\fs22  }{value, or it did not work properly. However, you can set }{\f2\fs20 -values}{\fs22  }{
to an array variable, IF you precede the @ with a \\ (for example,
\par }{\fs22 
\par \tab }{\f2\fs20 -values=>\\@food_values,}{\fs22 
\par }{\fs20\loch\af2 
\par }{* \tab }{\f2\fs20 -labels}{\fs22  }{is optional; if not given, the values are also the radio button labels. But if you DO put it, it REALLY must be a hash, and to use a hash variable, precede its % with a \\, as shown.
\par 
\par *\tab }{\f2\fs20 -linebreak}{\fs22  }{is indicating if you want the buttons in a vertical column.
\par 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\tab For more on radio button groups and other CGI.pm class goodies, the following documentation from CPAN can be helpful (there is also a link to this no
w from the course web page):
\par }{\b\fs22 
\par \tab }{\b http://theoryx5.uwinnipeg.ca/CPAN/perl/lib/CGI.html
\par 
\par 2.\tab }{A further note: it does indeed work to put "initial" HTML within the body of an }{\b 
\par }{\b\loch\af2 
\par }{\b\fs20\loch\af2 \tab }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 if (!param())
\par \tab \{
\par \tab \hich\af0\dbch\af0\loch\f2     ...
\par \tab \}
\par 
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {and the "response" HTML, then, in the corresponding else block.
\par 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\tab 
DO keep in mind that you are "redrawing" the page with each call --- if you are doing identical steps at the beginning of both the if and else blocks (such as calls to header(), for example), then put them BEFORE the if-else (following good progr
am abstraction). Likewise, identical statements at the end of both the if and else blocks should instead be performed after the if-else is complete.
\par 
\par \tab Keep this in mind for #3 and for the homework.
\par 
\par 3.\tab Write a script }{\b lab11_1.pl}{ that does the following:
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab uses CGI.pm functions to create HTML code, rather than typing it explicitly;
\par *\tab uses CGI::Carp to at least send fatal errors to the browser (fatalsToBrowser)
\par 
\par *\tab prints out HTML (with the help of CGI.pm) to display:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab the (window) title "Week 11 Lab Exercise"
\par *\tab your name in a header,
\par *\tab a radio button group with at least three radio buttons, with exactly one initially, explicitly checked,
\par *\tab and a submit button.
\par 
\par }\pard \s15\ql \fi-420\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab when the submit button is checked, lab11_1.pl reprints a new set of HTML that displays:
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab the same (window) title and your name in a header, (since these are always done, where should they be placed, hmmm?), and
\par *\tab prints the radio value selected.
\par 
\par }\pard \s15\ql \fi-420\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab Note that you should not see the radio buttons after a submission is made --- you'll just see the choic
e made. So, you need to put some of the "initial" HTML within appropriate logic (as implied in #2 above).
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {4.\tab Updating your }{\b 480perl.html}{ page as follows below is the last part of today's lab exercise. Remember to put these new items at the top (right after
 the <ul>, before the HW #8 items). Note, too, the different links when we are linking to a perl script directly instead of to an HTML page that calls a Perl script.
\par 
\par \tab So, add the following segment of code BEFORE the HW #8 section (and directly after the first}{\fs22  }{\f2\fs20 <ul>}{),}{\fs22  }{\b\ul REPLACING XXX with YOUR sorrel username!!!}{\b :}{
\par }{\fs22 
\par }{\fs20\loch\af2 \tab \hich\af0\dbch\af0\loch\f2 <li> HW #9
\par \tab \hich\af0\dbch\af0\loch\f2      <ul>
\par \tab \hich\af0\dbch\af0\loch\f2      <li> <a href=
\par \hich\af0\dbch\af0\loch\f2          "http://sorrel.humboldt.edu/cgi-bin/cgiwrap/}{\b\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 XXX}{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 /pref_both2.pl">    
\par \hich\af0\dbch\af0\loch\f2  \tab           pref_both2 </a>
\par \hich\af0\dbch\af0\loch\f2  \tab      </ul>
\par \tab \hich\af0\dbch\af0\loch\f2 <br>
\par 
\par }{\fs22 \tab }{\f2\fs20 <li> Week 11 Lab Exercise}{\fs22 
\par }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2         <ul>
\par \hich\af0\dbch\af0\loch\f2         <li> <a href=
\par \hich\af0\dbch\af0\loch\f2         "http://sorrel.humboldt.edu/cgi-bin/cgiwrap/}{\b\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 XXX}{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 /lab11_1.pl">    
\par \tab \hich\af0\dbch\af0\loch\f2           lab11_1 </a>
\par \hich\af0\dbch\af0\loch\f2    \tab     </ul>
\par \tab \hich\af0\dbch\af0\loch\f2 <br>
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {\fs22 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {When you believe you are done with the above, add your name to the "NEXT" list on the board. When it is
 your turn, I will come and try your script starting from your name link on the page http://www.humboldt.edu/~st10/f04cis480perl/480student_pages.html. 
\par (and, OK --- there's now a link to this from the course web page, in the "Other Course Links" section. Note that I will remove this link if anyone in class objects, however.)
\par 
\par If, by the end of lab, lab11_1.pl runs from there and meets the above specifications, then you will have met the requirements for this lab exercise. (Note that, this time, I also will
 need to actually look at your code, to verify use of CGI.pm and CGI::Carp; however, I will look at it during lab as part of your demonstrating it, rather than have you mail it in.)
\par }\pard \s15\ql \fi-420\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\ul HOMEWORK #9
\par }{
\par }{\b 1.}{\tab It is possible that, after Tuesday's lecture, you went ahead and used some of CGI.pm in your pref_both1.pl in HW #8. If you did, you are ahead of the game somewhat here, because for this homework you are now required to make this revision
 within a script }{\b pref_both2.pl}{, also meeting the following requirements:
\par 
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {*\tab use CGI.pm functions to create HTML code, rather than typing it explicitly;
\par *\tab use CGI::Carp to at least send fatal errors to the browser (fatalsToBrowser)
\par 
\par *\tab You will no longer have both an HTML file and a Perl script; you will just have a single scrip }{\b pref_both2.pl}{ that outputs HTML to display the initial options and then responds to the choices made when they are submitted.
\par 
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab (aside: the module HTML::Template can be used to separate design and code; since it is object-oriented, we'll wedge some object-oriented Per
l discussion along with our DBI discussion next week, to transition to this possibility, too. However, we will not be doing this in pref_both2.)
\par 
\par }\pard \s15\ql \fi-420\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab Design your code so that you do not see the radio button choices in your response (use param() as practiced in the lab exercise, in conjunction with if-else)
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }\pard \s15\ql \fi-420\li825\ri0\nowidctlpar\aspalpha\faauto\rin0\lin825\itap0 {*\tab include your name within the body of the web pages resulting from your Perl script (both initially and in responding to the user's submission)
\par 
\par *\tab initially:
\par }\pard \s15\ql \fi-420\li1260\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1260\itap0 {*\tab (remember to include your name in the body of the page)
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab set up a group of radio buttons for the options the user is to choose from;
\par *\tab include a check box the user can check if he/she would like to see the vote-totals so far;
\par }\pard \s15\ql \fi-420\li1260\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1260\itap0 {*\tab include a submit button, also;
\par 
\par }\pard \s15\ql \fi-420\li825\ri0\nowidctlpar\aspalpha\faauto\rin0\lin825\itap0 {*\tab when the submit button is pushed,
\par }\pard \s15\ql \fi-420\li1260\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1260\itap0 {*\tab (remember to include your name in the body of the page)
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab call the same subroutine as before to create the DBM file(s) if they are found to not exist;
\par }\pard \s15\ql \fi-420\li1290\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1290\itap0 {*\tab update the voting tallies to reflect the chosen radio button,
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {*\tab thank the user for his/her vote, including what he/she voted for and the total votes so far for that option
\par *\tab also print the vote-totals-so-far for all options IF the check box has been checked
\par }\pard \s15\ql \fi-420\li1695\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1695\itap0 {*\tab (I'll still not be picky about the format of this at this time, as long as it is reasonab
ly readable. BUT they should be ordered from highest-vote-getter to lowest-vote-getter,  in ASCIIbetical order of option for those with the same vote total. Remember that the br function can force a line break in HTML... 8-) ).
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }{\tab When you are done, make su
re that the pref_both2 link from 480perl.html (set up in the week 11 lab exercise) does indeed successfully run pref_both2. Make sure that pref_both2.pl is NOT world-readable (711 should make it executable but not readable.) 
\par 
\par \tab And, read pref_both2.pl into an e-mail message with the Subject 480 hw 8, and e-mail it, NOT as an attachment, to st10@humboldt.edu by the due date and time given above.
\par }{\b\fs22 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b\fs22 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs20 
\par }}