On to To Be Determined.
Held Monday, January 22, 2001
Summary
We begin the "course" with a consideration of its content, its purpose, and your expectations. In the second half of today's class, we begin consideration of the Perl programming language.
Notes
Due
Assignments
Notes
Overview
$i = 10;
$name = "SamR";
$names[5] = "Whatever";
@grades = ( "A", "B", "C", "D", "F" );
%gradevals = { "A" => 4.0,
"B" => 3.0,
"C" => 2.0,
"D" => 1.0,
"F" => 0.0 };
$firstname{"Rebelsky"} = "Sam";
my creates a local variable that disappears when the block
exits and is only available within the scope.
local termporarily replaces a global variable. The old value
is restored when the block exits. However, the new value of the v
ariable is accessible to all called procedures.
=.
<STDIN> reads one line from standard input and assigns it
to the variable $_.
$var = <STDIN> reads one line from standard input and
assigns it to the variable $var
print val1, val2, ... valn
print handle val1, ... valn
STDOUT (normal output),
STDERR (standard output),
and filehandles.
if (test) {
result1;
}
elseif (test) {
result2;
}
...
else {
resultn;
}
unless. We won't worry about it right now.
while (test) {
stuff;
}
foreach $var (array) {
stuff;
}
for (start; stop; step) {
stuff;
}
open(HANDLE, "> fname");
open(HTML, "> $base.html");
print HTML "<html>\n";
open(HANDLE, "< fname");
<HANDLE>
if (!open(DATA, "< datafile"))) {
print STDERR "Couldn't open data file.\n";
crash_and_burn();
}
while ($line = <DATA>) {
chop($line); # Get rid of the carriage return
@parts = split(/:/, $line);
print $parts[0], "\n";
}
close(DATA);
if ($stringvar =~ m/regexp/) {
...
}
<< provides an intersting way to grab a
lot of text (typically for output, but also for assigning to variables).
print STDOUT <<"STOPHERE"; <html> <head> <title>$title</title> </head> STOPHERE
On to To Be Determined.
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[News]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Quizzes]
[Readings]
[Reference]
Sets
[Login]
[Drop Box]
[Discussions]
[Grades]
Blackboard
[SamR]
Links
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Tue May 20 08:19:29 2003.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS397/2001S/outline.01.html.
You may validate
this page's HTML.
The source was last modified Tue Jan 23 09:48:09 2001.