{\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;}{\f31\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}
{\f32\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f34\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}{\f35\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}
{\f36\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f37\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}{\f38\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}
{\f47\fmodern\fcharset238\fprq1 Courier New CE;}{\f48\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f50\fmodern\fcharset161\fprq1 Courier New Greek;}{\f51\fmodern\fcharset162\fprq1 Courier New Tur;}{\f52\fmodern\fcharset177\fprq1 Courier New (Hebrew);}
{\f53\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f54\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f265\fswiss\fcharset0\fprq2 Arial Unicode MS Western;}{\f263\fswiss\fcharset238\fprq2 Arial Unicode MS CE;}
{\f264\fswiss\fcharset204\fprq2 Arial Unicode MS Cyr;}{\f266\fswiss\fcharset161\fprq2 Arial Unicode MS Greek;}{\f267\fswiss\fcharset162\fprq2 Arial Unicode MS Tur;}{\f268\fswiss\fcharset177\fprq2 Arial Unicode MS (Hebrew);}
{\f269\fswiss\fcharset178\fprq2 Arial Unicode MS (Arabic);}{\f270\fswiss\fcharset186\fprq2 Arial Unicode MS Baltic;}{\f273\fswiss\fcharset0\fprq2 @Arial Unicode MS Western;}{\f271\fswiss\fcharset238\fprq2 @Arial Unicode MS CE;}
{\f272\fswiss\fcharset204\fprq2 @Arial Unicode MS Cyr;}{\f274\fswiss\fcharset161\fprq2 @Arial Unicode MS Greek;}{\f275\fswiss\fcharset162\fprq2 @Arial Unicode MS Tur;}{\f276\fswiss\fcharset177\fprq2 @Arial Unicode MS (Hebrew);}
{\f277\fswiss\fcharset178\fprq2 @Arial Unicode MS (Arabic);}{\f278\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;}{\s18\ql \li0\ri0\widctlpar
\tqc\tx4320\tqr\tx8640\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext18 footer;}}{\info{\author Sharon Tuttle}{\operator CNRS}{\creatim\yr2004\mo8\dy2\hr14\min32}
{\revtim\yr2004\mo9\dy9\hr10\min18}{\printim\yr2004\mo9\dy2\hr9\min12}{\version8}{\edmins5}{\nofpages3}{\nofwords899}{\nofchars5128}{\*\company CNRS-HSU}{\nofcharsws6297}{\vern8269}}\margt2093 
\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 #3 and Week 3 Lab Exercise \tab \tab p. }{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 3}}}{
\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 3 LAB EXERCISE and Homework #3
\par 
\par week 3 lab exercise due: Thursday,  September 9th , END of lab
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 HW #3 due: Thursday, September 16th, 12:00 noon
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b\fs22 
\par }{\fs22 ------------------------------------------------------------------------------------------------------------
\par For}{\b\fs22  EACH }{\fs22 of the scripts below (lab exercise AND homework), you are required to begin}{\b\fs22  EACH }{\fs22 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 (}{\b\i\fs28\loch\af2 \hich\af0\dbch\af0\loch\f2 THEN}{\b\i\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2  }{\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 }{\b\i\fs20\loch\af2 
\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 }{\b ALSO: Note the following requirements for the following subroutines (in both the lab exercise }{\b\ul and}{\b  the homework):
\par 
\par }\pard \s15\ql \fi-405\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {*\tab precede each subroutine with a brief block comment summarizing what the subroutine does (this is SEPARATE from the overall-script block given above)
\par 
\par *\tab these subroutines must not use }{\b global}{ variables --- only arguments and lexical variables are permitted.
\par 
\par *\tab if a subroutine deliberately returns a value, it must be returned using the keyword }{\b return}{ in an appropriate fashion
\par 
\par }{\fs22 *\tab "name" your parameters within the subroutine as was discussed in lecture and in the course reading.
\par ------------------------------------------------------------------------------------------------------------}{\b\fs20\ul 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul WEEK 3 LAB EXERCISE
\par }{\b\fs20\ul 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 1.\tab }{Write a Perl script }{\b print_headings}{ that includes a subroutine named }{\b fancy_header}{
 which simply prints its arguments preceded by a blank line and a line of "******************************"'s, and followed by a line of  "******************************" followed by a blank line. (
The number of *'s doesn't matter --- put as many as you'd like.)  For example, calling:}{
\par 
\par }{\b &fancy_header("hello");
\par &fancy_header("how are you?");
\par &fancy_header("goodbye");
\par 
\par }{\tab should result in:
\par 
\par }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 ***********************************
\par \hich\af0\dbch\af0\loch\f2 hello
\par \hich\af0\dbch\af0\loch\f2 ***********************\hich\af0\dbch\af0\loch\f2 ************
\par 
\par \hich\af0\dbch\af0\loch\f2 ***********************************
\par \hich\af0\dbch\af0\loch\f2 how are you?
\par \hich\af0\dbch\af0\loch\f2 ***********************************
\par 
\par \hich\af0\dbch\af0\loch\f2 ***********************************
\par \hich\af0\dbch\af0\loch\f2 goodbye
\par \hich\af0\dbch\af0\loch\f2 ***********************************
\par 
\par }{\fs22 \tab In}{\b\fs22  print_headings, }{\fs22 call }{\b\fs22 fancy_header }{\fs22 
at least three times, with different arguments --- make at least one of the arguments a variable that was set to something that you asked the user to type in (that you read in from the user using <STDIN>).
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 
\par 2.\tab }{\fs22 Write a script }{\b\fs22 mark_draft}{\fs22  that outputs either the contents of the files passed to it as invocation arguments, or lines passed from standard/keyboard input, such that each line appears preceded by }{\b\fs22 DRAFT>> }{\fs22 
(with a space after the }{\b\fs22 >>}{\fs22 ).}{\b\fs22 
\par 
\par \tab }{\fs22 For example, if file george contains the 5 lines:
\par }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 the rain
\par \hich\af0\dbch\af0\loch\f2    in Spain
\par \hich\af0\dbch\af0\loch\f2 stays mainly
\par 
\par \hich\af0\dbch\af0\loch\f2    in the plain
\par }{\b\fs22 \tab 
\par }{\fs22 \tab then, if one called:
\par }{\b\fs22 
\par mark_draft george
\par 
\par }{\fs22 \tab ...then one would see:
\par }{\fs20\loch\af2 \hich\af0\dbch\af0\loch\f2 DRAFT>> the rain
\par \hich\af0\dbch\af0\loch\f2 DRAFT>>    in Spain
\par \hich\af0\dbch\af0\loch\f2 DRAFT>> stays mainly
\par \hich\af0\dbch\af0\loch\f2 DRAFT>> 
\par \hich\af0\dbch\af0\loch\f2 DRAFT>>    in the plain
\par }{\b\fs20 
\par \tab }{...on the screen.}{\fs20 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs22 When you are done, read both scripts into a single e-mail message with the Subject: line }{\b\fs22 480 lab 3 }{\fs22 (}{\b\fs22 NO ATTACHMENTS}{\fs22 ), and e-mail them to }{
\b\fs22 st10@humboldt.edu}{\fs22  by the }{\b\fs22 end}{\fs22  of }{\b\fs22 today's}{\fs22  lab.}{\b\fs22 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul 
\par HOMEWORK #3
\par 
\par }{\b\fs22 1.\tab }{\fs22 Write a Perl script }{\b\fs22 avg_play}{\fs22  that includes a subroutine named }{\b\fs22 avg}{\fs22  which expects a list of numbers as its argument. If the list is empty, it should }{\b\fs22 return}{\fs22 
 0 --- otherwise, it should }{\b\fs22 return}{\fs22  the average of the numbers within its argument list.(So, note that }{\b\fs22 avg}{\fs22  does not print anything --- it returns its result to the caller.)}{\b\fs22 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par \tab }{\b avg_play}{ should call }{\b avg}{ at least twice:
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab once with an empty list,
\par *\tab once with a list with numbers;
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\tab For }{\b each}{ }{\b call}{ of }{\b avg}{, }{\b avg_play}{ should print a message showing what its argument was, what you THINK it should return, and then}{\b  }{
what it actually returned.
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 2.\tab }{Write a Perl script }{\b picky_avg_play}{ that includes a subroutine named }{\b picky_avg}{
, which expects a list of numbers as its argument. It will compute and return the average of the numbers in its argument that are between 70 and 100, exclusive, only; i
t should return -1 if there are no such numbers in its argument list. (Again, make sure that }{\b picky_avg}{ contains no print statements... it returns its result only.) 
\par 
\par \tab }{\b picky_avg_play}{ should call }{\b picky_avg}{ at least three times:
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab once with an empty list,
\par *\tab once with a list that has numbers, but none between 70 and 100,
\par *\tab once with a list that has numbers, some between 70 and 100 and some not
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 \tab }{\fs22 After each call of}{\b\fs22  picky_avg, picky_avg_play }{\fs22 should print a message showing what its argument was, what you THINK it 
should return, and then what it actually returned.
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 
\par }{\b\fs22 3.\tab Consider mark_draft}{\fs22  above (#2 in the lab exercise). Now create a script }{\b\fs22 mark_draft2}{\fs22  that performs the same action, except that if NO command-line arguments are given (if not even one file name is given
 as an invocation argument), it instead prompts the user to enter a file name, and then acts on that file's contents. (lines cannot be passed by standard input into}{\b\fs22  mark_draft2}{\fs22 ...)}{\b\fs22  
\par 
\par 4.\tab }{\fs22 Write a script}{\b\fs22  dollar_avg }{\fs22 that asks for dollar amounts from the user (
entered as a list of plain numbers, ending with control-d). It should average the numbers entered, and print the averaged result to two decimal places with a $ sign in front; iff no values are entered, print that no average was computed. For this script, 
you are to write this so that you read and process }{\b\fs22 one line}{\fs22  at a time.)}{\b\fs22 
\par 
\par 5.\tab }{\fs22 Write a script}{\b\fs22  get_marked }{\fs22 that expects file names given as invocation arguments (or it prompts the user for a file name if no invocation arguments are given). It then outputs to the screen }{\b\fs22 only}{\fs22 
 those lines within those file(s) that contain the string }{\b\fs22 <MARK>}{\fs22  anywhere within them. For this script, also, you are to write this so that you read and process }{\b\fs22 one line}{\fs22  at a time.}{\b\fs22 
\par 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs22 When you are done, read all of these scripts  into a single e-mail message with the Subject: line}{\b\fs22  480 hw 3 }{\fs22 (}{\b\fs22 NO ATTACHMENTS}{\fs22 )}{\b\fs22 , }{\fs22 
and e-mail them to}{\b\fs22  st10@humboldt.edu }{\fs22 by the due date and time given above.}{\b\fs22 
\par }{\fs22 (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.)}{\b\fs20 
\par }}