Section for Week 3, Tuesday, 1/26/99
REVIEW FOR QUIZ (1-3)
---------------------
1. UNIX vs. Perl vs. HTML
UNIX commands we've seen: wc, sort, grep, more, perl5, etc.
Perl commands we've seen: print, if/then/else, while, for, foreach, etc.
HTML commands:
,
, ,
, etc.
Make sure you know what items fall into which categories and what
everything is used for. Most of the UNIX commands you've seen are in
the warmup handout, so review it if you need to.
2. Command-line arguments: any arguments you give your script will be
placed in @ARGV. The command "scriptname file1 file2 file3" will result
in @ARGV = ("file1", "file2", "file3") (so first argument is in
$ARGV[0]). The command name is stored in $0, in case you need it.
3. Input/Output for filter use: grep, sort are examples.
In Perl, mostly use <> for this sort of program: if @ARGV is non-empty,
<> will read from each file named on the command line in turn. If @ARGV
is empty, read input from stdin. If you want to, you can set @ARGV
*within* your script to force reading out of specific files using the <>
operator.
OTHER TOPICS
------------
4. "Here" documents: If you want a string that spans multiple lines and is
complicated, you might not want to string together quoted lines (esp. if
the string contains all manner of quotes inside it). Use a "here"
document:
print << "EOF";
Content-type: text/html
alpha game
The alpha game
EOF
Vital that the last line have no other characters (here documents are
terminated by the *LINE*, not just the EOF string. Could use any other
string as well...
5. Remember there's a midterm friday of fourth week (in MS5200).