{\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;}{\f39\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}
{\f40\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f42\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}{\f43\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}
{\f44\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f45\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}{\f46\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}
{\f55\fmodern\fcharset238\fprq1 Courier New CE;}{\f56\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f58\fmodern\fcharset161\fprq1 Courier New Greek;}{\f59\fmodern\fcharset162\fprq1 Courier New Tur;}{\f60\fmodern\fcharset177\fprq1 Courier New (Hebrew);}
{\f61\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f62\fmodern\fcharset186\fprq1 Courier New 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;}{\f281\fswiss\fcharset0\fprq2 @Arial Unicode MS Western;}{\f279\fswiss\fcharset238\fprq2 @Arial Unicode MS CE;}
{\f280\fswiss\fcharset204\fprq2 @Arial Unicode MS Cyr;}{\f282\fswiss\fcharset161\fprq2 @Arial Unicode MS Greek;}{\f283\fswiss\fcharset162\fprq2 @Arial Unicode MS Tur;}{\f284\fswiss\fcharset177\fprq2 @Arial Unicode MS (Hebrew);}
{\f285\fswiss\fcharset178\fprq2 @Arial Unicode MS (Arabic);}{\f286\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{\author Sharon Tuttle}{\operator CNRS}{\creatim\yr2004\mo8\dy2\hr14\min32}
{\revtim\yr2004\mo9\dy23\hr16\min1}{\printim\yr2004\mo9\dy23\hr11\min35}{\version4}{\edmins16}{\nofpages3}{\nofwords826}{\nofchars4712}{\*\company CNRS-HSU}{\nofcharsws5786}{\vern8269}}\margt2093 
\deftab1250\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\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 5 LAB EXERCISE and Homework #4
\par 
\par week 5 lab exercise due: Thursday,  September 23rd , END of lab
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22 HW #4 due: Thursday, September 30th, 12:00 noon
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs22 ---------------------------------------------------------------------------------------------------------
\par }{\b\fs22 For EACH of the scripts below (lab exercise AND homework), you are required 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 \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 
\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\fs22 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul WEEK 5 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 script }{\b tab_counter}{
 that prints to the screen the number of lines containing one or more tab characters that it finds in the files passed to it as invocation arguments. (this can be cat-like, and handle lines typed to standard input if no command-line arguments are given.)}
{
\par 
\par }{\b 2.\tab }{Write a perl script }{\b shout_words}{ that will output all of the lines in the files passed to it as invocation arguments to the screen, except that any word (a Perl-style word, for simplicity) that start
s with an uppercase letter will be replaced with that word in all-uppercase.}{\b 
\par }{
\par \tab For example, the line:
\par \tab Hi hi Hello george geOrge George
\par 
\par \tab ...would be output as:
\par \tab HI hi HELLO george geOrge GEORGE
\par 
\par \tab (again, this can be cat-like, and handle lines typed to standard input if no command-line arguments are given.)
\par 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {When you are done, read both scripts into a single e-mail message with the Subject: line }{\b 480 lab 5 }{(}{\b NO ATTACHMENTS}{), and e-mail them to }{\b st10@humboldt.edu}{ by the }{
\b end}{ of }{\b today's}{ lab.}{\b 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs22\ul 
\par HOMEWORK #4
\par 
\par }{\b 1.\tab }{While we are awaiting our coverage of file I/O, note the following kluge: you can directly set $ARGV[0] so that you can then use the diamond operator to handle every line in a given file name. Yes, you
 can even do this within a loop (set @ARGV at the beginning of the loop and then have a nested loop using <>).}{\b 
\par }{\b\fs22 
\par \tab }{\fs22 You have an application that has a problem with input files that contain tab characters. As a first step to dealing with this, you want to know which files in the current working directory even *contain* tabs.
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 \tab 
Write a Perl script tab_finder that will print to the screen, one file name per line, the names of files in the current working directory that contain any tab characters.
\par }{\b\fs22 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 2.\tab }{#1 was a first step --- here is a next step. You now want to convert files containing tabs so that they no longer contain tabs. Write a Perl script }{\b 
tab_be_gone }{that will echo back all of the lines in files in its command line, EXCEPT:}{
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab if a line begins with a tab or tabs, each such "initial" tab will be replaced by 4 spaces;
\par 
\par }{\b [rephrased 4:00 pm 9-23-04]}{
\par *\tab if a line ends with }{\b one or more tabs}{, }{\b all such trailing tabs}{ should simply be removed;
\par 
\par *\tab if a line has a tab within it (neither at the beginning or the end), it should be replaced with a single blank. 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }{\b\fs22 \tab }{\fs22 (Then a UNIX user could redirect the output to a file of their choice, by calling this script with > ...) (note: this, too, can be cat-like, and handle lines typed to standard input if no command-line arguments are given.)
\par }{\b\fs22 
\par 3.\tab }{\fs22 Somebody has written all of the Java file names in a file so that they end in }{\b\fs22 .jav }{\fs22 --- but  they should really be ending in }{\b\fs22 .java}{\fs22 , of course! Write a Perl script }{\b\fs22 fix_java_suffixes1}{\fs22 
 that will change any word *ending* in }{\b\fs22 .jav}{\fs22  so that it now ends in}{\b\fs22  .java}{\fs22 .
 (It should do so for all lines contained within files given on its command line --- it should output to the screen, so that one can redirect to a file using > if he/she desires.) (note: this, too, can be cat-like, and handle lines typed to standard input
 if no command-line arguments are given.)}{\b\fs22 
\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\fs22 4.\tab }{\fs22 Note that Perl's }{\b\fs22 system}{\fs22 
 command is another way (besides using back-quotes) to run a native operating system command from within Perl; however, back-quotes allow you to set a Perl variable to the result of that operating system command.}{\b\fs22 
\par 
\par \tab }{\fs22 Consider fix_java_suffixes1 --- it fixed file names within a file. What if you want to really fix the file_names within the current working directory? Write a script fix_java_suffixes2 that will change the names of files in the c
urrent working directory that end in .jav so that they end with .java instead.
\par }{\b\fs22 
\par 5.\tab }{\fs22 Write a Perl script }{\b\fs22 fudd_converter}{\fs22  --- it outputs to the screen all of the lines in files in its command line, except it first converts them into "Elmer-Fudd"-speak as follows:}{\b\fs22 
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs22 *\tab every r (regardless of case or word position) should be converted to a w (of the same case);
\par 
\par *\tab every l (lower-case el) (regardless of case or word position) should be converted to a w (of the same case);
\par 
\par *\tab a word that *ends* in th (regardless of case) should have the th converted to an f (of the same case);
\par 
\par *\tab a word with th in any position but the end (regardless of case) should have the th converted to a d (of the same case).
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs22 \tab Optional: if you'd like, you can figure out when a Fudd-chuckle (uh-huh-huh-huh) should be inserted. I cannot think of a "pattern" for when these should occur.

\par 
\par \tab (note: this, too, can be cat-like, and handle lines typed to standard input if no command-line arguments are given.)
\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 all of these scripts  
into a single e-mail message with the Subject: line 480 hw 4 (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\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\fs20 
\par }}