{\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;}
{\f44\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}{\f45\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f47\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}
{\f48\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}{\f49\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f50\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}
{\f51\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}{\f60\fmodern\fcharset238\fprq1 Courier New CE;}{\f61\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f63\fmodern\fcharset161\fprq1 Courier New Greek;}
{\f64\fmodern\fcharset162\fprq1 Courier New Tur;}{\f65\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f66\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f67\fmodern\fcharset186\fprq1 Courier New 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\langnp0\langfenp255 Numbering Symbols;}}{\info
{\author Sharon Tuttle}{\operator CNRS}{\creatim\yr2004\mo8\dy2\hr14\min32}{\revtim\yr2004\mo10\dy17\hr23\min35}{\printim\yr2004\mo9\dy9\hr10\min40}{\version8}{\edmins2}{\nofpages3}{\nofwords860}{\nofchars4907}{\*\company CNRS-HSU}{\nofcharsws0}
{\vern8269}}\margt2079 \deftab1250\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\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 #7 and Week 8 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 {\fs22 CIS 480 - Perl in Depth - Fall 2004
\par WEEK 8 LAB EXERCISE and Homework #7 }{\b\fs22 REVISED
\par 
\par }{\fs22 week 8 lab exercise due: }{\b\fs22 Thursday,  October 14th , END of lab}{\fs22 
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 HW #7 due: }{\b\fs22 Thursday, October 21st, 12:00 noon}{\fs22 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs22 ---------------------------------------------------------------------------------------------------------
\par For EACH of the scripts below (lab exercise AND homework), you are required to begin EACH with the following:
\par }{\fs20 
\par }{\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}{\fs20\loch\af2 
\par \hich\af0\dbch\af0\loch\f2 ###480-scriptname: }{\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 yourScriptName}{\fs20\loch\af2 
\par }{\i\fs20\loch\af2 
\par \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 hope to develop a Perl script to process these in some interesting and useful fashion. More on that as it develops.
\par --------------------------------------------------------------------------------------------------------
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul WEEK 8 LAB EXERCISE
\par }{\b\fs20\ul 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 1.\tab }{\fs22 Remember the alphameric }{\b\fs22 get_median }{\fs22 from HW #2? (You can find a version on the course Blackboard site, under "Selected Solutions".) 

\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 \tab Modify it to create }{\b\fs22 better_median}{\fs22  that uses a sort subroutine to compute the *numeric* median. I
t can still return the middle value for an odd number of values, and both middle values for an even number of values.
\par }{\b\fs22 
\par \tab }{\fs22 When you are done, read this script into a single e-mail message with the Subject: line }{\b\fs22 480 lab 8 PART 1 }{\fs22 (}{\b\fs22 NOT }{\fs22 using atachments), and e-mail it to }{\b\fs22 st10@humboldt.edu}{\fs22  by the }{\b\fs22 end}{
\fs22  of }{\b\fs22 today's}{\fs22  lab.}{\b\fs22 
\par 
\par 2.\tab }{\fs22 Let's play with command-line in-place editing. Create some files whose names being with }{\b\fs22 perlab}{\fs22  and end with }{\b\fs22 .txt}{\fs22 . Make sure that they contain some lines that contain your first and last name.}{\b\fs22 

\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 
\par \tab }{\fs22 
Write a perl command-line command that will edit all such files, adding a middle initial to your name wherever it occurs in those files, making a backup of those files ending with the suffix .bak . Write a second perl command-line command that will also e
dit all such files, removing the middle initial from your name, and making a backup of those files ending with the suffic .bak .
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 \tab When you believe these are working, add you name to the "NEXT" list on the board. When it is your turn, I will come and allow 
you to demonstrate these two commands, checking after each that the appropriate files have indeed been changed. If your demonstration works as described above, then you will receive full credit for this part of the lab exercise.
\par }{\b\fs22 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul \page HOMEWORK #7
\par 
\par }{\b\fs22 1.\tab }{\fs22 Recall }{\b\fs22 pref_count}{\fs22  and }{\b\fs22 pref_results }{\fs22 
from HW #5; DBM files sure look like an interesting option for revising these. You'll find versions of these on the course Blackboard site, under "Selected Solutions".}{\b\fs22 
\par 
\par \tab }{\fs22 Modify these into }{\b\fs22 pref_count2}{\fs22  and }{\b\fs22 pref_results2}{\fs22 
 that use either one or two DBM hash(es) in their implementation (it is your choice whether to use one or two DBM hashes; I modified these to use just one, but that was using a bit of a "klugy" approach and not caring what order the options are displayed 
in pref_count2). (You can of course change the topic of the survey... 8-) ) Some additional requirements:
\par 
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {\fs22 *\tab you will not be using counter-files this time; the only files permitted are DBM files (and, again, you may choose to use either one or two sets of such files).

\par 
\par *\tab instead of hard-coding two hashes at the beginning of these new scripts, they should check to see if the one or two sets of DBM file(s) exist. If they do not, then they should call a subroutine to open and "seed" these files with your chosen
 options with initial votes of 0.
\par 
\par }\pard \s15\ql \fi-420\li1275\ri0\nowidctlpar\aspalpha\faauto\rin0\lin1275\itap0 {\fs22 *\tab 
(Why are we "seeding" them in this way, if you can easily add to a hash? Because, in this case, we still want to be able to limit users' votes to a fixed set of options...)
\par 
\par *\tab note: you are required to open and close the hash(es) within this subroutine. That way, you should be able to assume you can safely open it/them once your script has determined that these files exist.
\par }{\b\fs22 
\par }\pard \s15\ql \fi-420\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs22 *\tab these scripts can then safely open the DBM hash(es), and pref_count2 can use it/them to update 
the user's selected option's vote total and show the new vote total for that option, and pref_results2 can use it to show the current vote totals.
\par 
\par *\tab But ... we now know about sort subroutines too, don't we? 8-) So, }{\b\fs22 pref_results2}{\fs22 
 should show the current voting results from the highest-total option to the lowest-total option. If two options have the same vote total, those options should be displayed in ASCIIbetical order. }{\b\fs22 (revised 10-18-04)
\par 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 2.\tab }{\fs22 A professor has created a number of files in a directory; each is named }{\b\fs22 course}{\fs22  followed by something, ending with the suffix }{
\b\fs22 .list}{\fs22 . (for example, }{\b\fs22 course315.list}{\fs22 , }{\b\fs22 course480.list}{\fs22 , etc.) Within each file, each line contains a student's sorrel username, some white space, and then the student'
s name. (That part is easy to create from WebReg and a spreadsheet... 8-) ).}{\b\fs22 
\par 
\par \tab }{\fs22 This professor has hired you to convert these files such that, instead of a username and the student's name, each line contains a link to that student's homepage on sorrel. That is, for the line:
\par }{\b\fs22 
\par \tab }{\b\f2\fs20 st10    Sharon Tuttle}{\b\fs22 
\par 
\par \tab }{\fs22 ... the line should be changed to:}{\b\fs22 
\par 
\par \tab }{\b\f2\fs20 <li> <a href="http://www.humboldt.edu/~st10"> Sharon Tuttle </a>}{\b\fs22 
\par }{\b\fs20\loch\af2 
\par \tab }{You must write a Perl script}{\b  add_links }{to accomplish this using in-place editing (modifying }{\b $^I}{ ), storing the original file versions in files ending with }{\b .orig }{ . }{\b\fs20\loch\af2 
\par }{\b\fs22 
\par \tab }{\fs22 (Hints: }{\b\fs22 
\par }\pard \s15\ql \fi-420\li840\ri0\nowidctlpar\aspalpha\faauto\rin0\lin840\itap0 {\fs22 *\tab note that sorrel usernames always end in digits. And, you may assume that student names do not contain digits.
\par 
\par *\tab nothing says you have to accomplish all of the above in a single substitution expression... 8-) In fact, a carefully-ordered sequence of substitutions is easier, I think.
\par 
\par *\tab remember that you can use a character other than / in s//
\par )
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs22 When you are done, read both of these scripts  into a single e-mail message with the Subject: line }{\b\fs22 480 hw 7}{\fs22 
 (using NO ATTACHMENTS), and e-mail them to st10@humboldt.edu by the due date and time given above.
\par 
\par (remember, you can use ^R within your properly-configured pine on cs-server to copy a file's contents reliably into an e-mail message.)
\par }\pard \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b\fs20 
\par }}