$name = "John Doe"; $salary = 500.00;
$#listname
: last index of a list@teams = ("Bulls", "Rockets", "Pacers");
@scores = (42, 45, 50, 35, 40);
@weird1 = ("Age", 50, "income", 50000);
$scores[3] = 42;
%weird2 = ("Age", 50, "income", 50000);
$weird2{"Age"} = 65;
$foo = @scores; %weird3 = @weird1;
@weird4 = $weird2
+ - ++ -- * /
> < >= <= == !=
<=>
gt lt ge le eq ne
print 'Single quoted: hello$foo@weird1\n';
print "Double-quoted: hello$foo@weird1\n";
keys(%weird2)
each(%weird2)
{ ... }
separated
by semicolonsif
statements:
if (condition) block elsif (condition) block ... else block
unless (false-condition) block
block unless (false-condition)
while (true-condition) block
do block while (true-condition)
until (false-condition) block
do block until (false-condition)
for (initialize; true-condition; update) block
foreach var (list) block
$foo = <STDIN>; # Read one line from keyboard
@jumbo = <STDIN>; # Read all lines into a list
print STDERR "This is an error message\n";
printf STDOUT "A formatted Error message: %d: %s\n", $code, $mesg;
open(INPUTFILE, "/u/asengupt/apache/logs/access_log"); # Read
open(OUTPUTFILE, ">test.out"); # Write
sampleline = <INPUTFILE>;
print OUTPUTFILE "This goes to a file\n";
dbmopen(%a "file", 0644);
print $a{$mykey}, "\n";
dbmclose(%a);
@ARGV
: list of command-line arguments$0
: Name of the perl script$!
: Last error messagechomp(string)
: chops the last charactershift, unshift
take out/put in element in a
list (from the left)push, pop
use list as a stack (from the
right)while (<>) { print $_; }
foreach (@names) { print $_; }
if /pattern/ { print $_; }
while(<>) { print; }
man perlfunc
abs,sqrt,log,rand,srand
push, pop, shift,
unshift
chomp, index, length, substr
split, join
#!/usr/local/bin/perl # Open some file for reading, could be STDIN open(INFILE, "some/filename"); while($line = <INFILE>) { if ($line =~ /some_pattern/) { # ok, this line matches the pattern. } else { # this line does not match the pattern } }RE operators
/pattern/
operator: includes a pattern against which
matching is to be performed=~
operator: compares a variable with the given
pattern.s/pattern/string/
operator: can be used with
=~
to replace pattern with string./hello/
matches if the given string
contains "hello" anywhere. e.g., "hello world", "Joe says
hello"/hello/i
- as above, but
the pattern is case insensitive. Matches "hello", "Hello",
"hElLo", etc./^hello/
matches the pattern
only if it appears in the beginning of the
string. /hello$/
matches at the end..
matches any character except a
newline (\n)[abcdefgh]
matches one of the given
characters.[0-9]
is the same as
[0123456789
[^abcdef]
matches a character not in
the given set\/
\( \) \{ \} \[ \] \$ \\ \? \* \+
\d
(digit),
\s
(white space character), \D
non-digits, \S
non-space characters(p)
matches one p - useful for multiplying a
complex patternp?
matches 0 or 1 pp*
matches 0 or more p'sp+
matches 1 or more p'sp{m,n}
matches at least m p's, no more than n
p'sif /(pat1)...(pat2)...(pat3)/ { print $1, $2, $3;
}
Java Basics
<APPLET>
and <PARAM>
Tags
<APPLET CODE = name of applet (.class file) WIDTH = width of applet (pixels) HEIGHT = height of applet (pixels) CODEBASE = URL of applet ALT = alternate text to display NAME = applet's name ALIGN = alignment VSPACE = extra whitespace above and below the applet HSPACE = extra whitespace to either side of applet > <PARAM NAME="param 1" VALUE="value 1"> <PARAM NAME="param 2" VALUE="value 2"> ... Alternative HTML code to display </APPLET>
<APPLET>
Tag
<PARAM>
Tag Unpaired and contains two required attributes, NAME and VALUE:
Each PARAM corresponds to a named parameter.<PARAM NAME=score VALUE=120>
An HTML document consists of text interspersed with markup tags. Tags never appear in the printed text, but silently guide the browser behind the scenes. Tags are surrounded by left and right angle brackets and often, but not always, occur in pairs.
Escaping: <
is used to produce <
Basic HTML Tags
A complete HTML document always begins with the tag <HTML>
and ends with the tag </HTML>
. Within the document there
are two sections: the head, bracketed by <HEAD>
and
</HEAD>
(contains identifying and control information
that isn't part fo the displayed text) and the body bracketed by
<BODY>
and </BODY>
(the user
readable text)
<H1>
through <H6>
paired
<P>
paired or not
<A>
to Create a Link
<a href="/images/pic1.gif">Relative Link</a>
<a href="#name">Local Link</a>
<A>
to Create a Link target
<a name="here">Some text</a>
<a href="http://www.cc.columbia.edu">External Link</a>
<IMG SRC="http://www.cc.columbia.edu/low3.gif">
<IMG SRC="http://www.cc.columbia.edu/low3.gif" ALT="Columbia U">
<A HREF="http://www.cc.columbia.edu"> <IMG SRC="http://www.cc.columbia.edu/low3.gif"> </A>
Physical
Related Tags
Y
is Y (ASCII code between # and ;).
<BLOCKQUOTE>
<PRE>
<HR>
Ordered, unordered.
<ul> <li> Item 1 <li> Item 2 <li> Item 3 </ul>
Definition lists:
<DL> <DT> Term 1 <DD> Definition of term 1 <DT> Term 2 <DD> Definition of term 2 </DL>
<BODY BGCOLOR=white>
<BODY BACKGROUND="http://www.cc.columbia.edu/low3.gif">
All tags are paired and have params.
There's a similarity between frames and images and applets in some sense.
<FRAMESET ROWS="45%,45%,10%"> <FRAME SRC="text.html" NAME="text"> <FRAME SRC="figure1.gif" NAME="figure"> </FRAMESET>
4. Review of Apache Installation
We've covered this in the lab and in lecture 3
Also inthe same lecture:
Also protecting the server
against machine reboots with
Steve Kinzler's starthttpd
and crontab