Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Table of Contents


Index

Note to the Reader: Throughout this index, first-level entries are boldface. Boldface page numbers indicate primary discussions of a topic. Italic page numbers indicate illustrations.

Symbols

& (ampersand)
as logical AND operator (&&), 301, 409
in URLs, 121, 124
>> (append operator), 97, 98
* (asterisk) in regular expressions, 132
@ (at sign) in lists, 24–25
\ (backslash)
for escaped characters in Perl, 19–20
newline character (||n), 19
in regular expressions, 132
{ } (braces) in subroutines, 52
^ (caret) in regular expressions, 132
, (comma) in file handle syntax, 101
$ (dollar sign)
global variable ($!), 170, 408
in regular expressions, 132
scalars and, 23, 97
“(double quote)
escaped double quote (||”), 20
in lists, 26
== (equal to operator), 105
! (exclamation point)
in comments, 18
global variable ($!), 170, 408
not equal to operator (!=), 105
/ (forward slash) in UNIX, 15
> (greater than operator), 105
>= (greater than or equal to operator), 105
<< (here operator), 296–297
< (less than operator), 105
<= (less than or equal to operator), 105
|| (logical OR operator), 155, 170, 409
!= or <=> (not equal to operators), 105
( ) (parentheses)
in regular expressions, 133
in while statements, 77
% (percent sign)
in associative arrays, 72
in URLs, 121, 124
. (period)
directory notation in UNIX and Windows, 238
in regular expressions, 132
string concatenation operator, 226–227
+ (plus sign)
in regular expressions, 132
in URLs, 124
# (pound sign)
as comment character in hosts files, 60–61
as comment character in Perl, 15, 18
in server-side includes directives, 189
? (question mark) in regular expressions, 132
< > (redirection operators), 97–98
; (semicolon) in Perl, 19
’ (single quote) in lists, 26
_ (underscore) in Perl, 54–55

A

abs function, 346
accept function, 346
access counters. See counters
ActiveX controls, 34
adding
boilerplate to HTML documents, 191, 192–194, 193
guest book entries, 166–168, 168, 169
addresses
gethostbyaddr function, 308–310, 357–358
getnetbyaddr function, 358–359
IP addresses, 409
and controlling counters, 103–106
hosts files and, 60–62, 61, 305–306
in log files, 219, 235
programming for, 305–306
resolving with Perl, 306–311, 308
loopback addresses, 61
alarm function, 346–347
Allen, Paul, 279
ampersand (&)
as logical AND operator (&&), 301, 409
in URLs, 121, 124
analyzing programming problems, 91–92, 92
AND operator (&&), 301
Apache Web server software, 283, 406
append operator (>>), 97, 98
applets, 5, 406
applet extension to HTML, 260, 263
Application MIME type, 83
applications, parent and child applications, 69–70, 70
arguments, 18
ARGV lists, 293
arithmetic operators, 99
Arnold, Ken, 304
arrays. See also lists
associative arrays, 72, 406
delete function, 352
each function, 76–77, 353
initializing, 73–75
keys function, 76, 366–367
sorting, 81–82, 82, 385
values function, 76, 393
join function, 366
pack function, 130–131, 170–173, 373–374
pop function, 374
reverse function, 379
shift function, 383
splice function, 385–386
split function, 386
decoding URL query strings, 126–127
extracting log file information, 223–227, 225
unshift function, 392–393
wantarray function, 394
asterisk (*) in regular expressions, 132
at sign (@) in lists, 24–25
atan2 function, 347
attributes of SGML elements, 256
Audio MIME type, 84
automating URLs with frames, 107–109, 108, 109
awk command in UNIX, 9

B

backslash (\)
for escaped characters in Perl, 19–20
newline character (||n), 19
in regular expressions, 132
BASEFONT Netscape HTML extension, 260
Berkeley Systems Development (BSD) UNIX, 303–304
Berners-Lee, Tim, 400–401
bind function, 347
binmode function, 347
bless function, 347
BLINK Netscape HTML extension, 260
boilerplate, adding to HTML documents, 191, 192–194, 193
Boolean values, 152
braces ({ }) in subroutines, 52
browsers, 401–403, 402, 406
communications with HTTP servers, 56–57
deciding which to support, 282, 284
Java applets and, 5
BSD (Berkeley Systems Development) UNIX, 303–304
bus architecture, 273

C

C and C++ languages, 406
argv lists, 293
as CGI programming languages, 31–32, 31
#include directive, 51
UNIX and C language, 9–10, 10
caller function, 348
capitalization. See case
caret (^) in regular expressions, 132
case
case sensitivity in Perl, 23
lc function, 367–368
lcfirst function, 368
CENTER Netscape HTML extension, 260
central processing units (CPUs). See microprocessors
CERN (European Laboratory for Particle Physics), 190, 400–401, 406
CGI (Common Gateway Interface), 6, 26–34, 56–59, 66–87, 406–407
CGI programming languages, 31–34
ActiveX controls, 34
C and C++, 31–32, 31
JavaScript, 5–6, 6, 34
proprietary CGI methods, 34
shell scripts, 33–34
Visual Basic, 32–33, 33
CGI specification information, 30
displaying environment variables in HTML documents, 72–82
display program explained, 75–76
each function, 76–77, 353
running the example, 77–80, 78, 79
sorting associative arrays, 81–82, 82
while statements, 76–77
writing the display program, 72–75
environment variables, 30, 30, 66–82, 103–104, 407
common variables listed, 71
in counters, 103–104
setting, 69–70, 70
using, 66–68, 67, 69
HTTP, HTML and, 56–58, 56, 58
HTTP servers and, 29
MIME and, 58–59, 59
Perl and, 26–28, 27, 28
security and running CGI applications, 324
World Wide Web and, 26–29, 27, 28
chdir function, 348
child applications, 69–70, 70
chmod function, 348
chomp function, 348–349
chop function, 231, 349
chown function, 349
chr function, 349
chroot function, 349–350
close function, 94–96, 350
closedir function, 350
comma (,) in file handle syntax, 101
command line, 15
commands. See also server-side includes
UNIX commands, 8
comments
comment character (#) in Perl, 15, 18
in hosts files, 60–61
in HTML, 189
in Perl, 22
Common Gateway Interface. See CGI
Common Log Format, 219–221, 220, 407. See also log files
extracting information, 227–231, 229
making IIS logs compatible with, 221–222, 222
compiled languages, 11–12
compiling Perl source code, 14
CompuServe GIF format, 205
conditional statements, 104, 407
foreach statements, 242–243
if statements
in access counters, 104–106
in database searches, 293, 302
in quiz forms, 154–156
last function, 367
next function, 371
for statements
in guest book example, 179–180
in log file extraction example, 236–238
while statements, 76–77
in log file extraction example, 230
read function in a while loop, 178–179
#config server-side includes directive, 191, 198–200, 199
configuring Windows NT Registry for HTTP servers, 40–44, 41
connect function, 350
converting guest books into command-line searchable databases, 288–293, 289, 292
cos function, 350
counters, 90–110, 153–154, 205–212, 407. See also log files
access counter example, 101–110
automating URLs with frames, 107–109, 108, 109
controlling what gets counted, 103–104
environment variables, 103–104
HTML and, 106–107
if statements, 104–106
making the access counter graphical, 206–208, 209
relational operators, 105–106
running the counter, 106–107, 107
wrappers, 101–102, 103
analyzing the problem, 91–92, 92
designing the solution, 92–93, 93
file manipulation and, 94–101
append operator (>>), 97, 98
close function, 94–96, 350
file handles, 96–97
open function, 94–96, 371–372
overview of file handling functions, 94–95, 95
print function, 94–95, 99–101
read function, 94–95, 100
redirection operators (< >) for input and output, 97–98
write function, 94–96, 100, 102, 395
graphical access counter example, 205–212
local function, 209–210, 369
making the access counter example graphical, 206–208, 209
pipe function, 211, 374
PostScript code, 209, 212
print function GS parameter, 210
program explanation, 209–212
variables, 210–211
implementing the solution, 93
overview of, 90–91, 90
in quiz forms, 153–154
CPUs. See microprocessors
creating
database searches in HTML, 294–297, 295, 298
ender code files, 51–52
guest books, 162–166, 163, 165
Hello World script example, 15
HTML code and displaying on Web servers, 45–55
creating ender code files, 51–52
creating HTML code, 45–46
extending subroutines with header files, 53–54
installing ender code files, 52–53
MIME headers, 48–49
print statements, 50–51
require function, 50–55
running, 47, 47
subroutines, 49–50, 50, 52
underscore (_), 54–55
password files, 328–330
crypt function, 351
csh command in UNIX, 8
curly braces ({ }) in subroutines, 52

D

daemons in UNIX, 42
DARPA (Defense Advanced Research Project Agency), 399
data, Parkinson’s Law of, 274
databases, 171, 288
dbmclose function, 351
dbmopen function, 351
records, 288
searching, 288–303
converting guest books into command-line searchable databases, 288–293, 289, 292
creating database searches in HTML, 294–297, 295, 298
searching on multiple fields, 298–303, 300, 302
wildcards in, 299, 301
dates
configuring display with server-side includes, 191, 198–200, 199
in UNIX Common Log Format, 221
dbmclose function, 351
dbmopen function, 351
decoding
log files, 217
query strings in URLs, 120, 126–127, 127
Defense Advanced Research Project Agency (DARPA), 399
defined function, 351
delete function, 352
deleting guest book entries, 336–341, 339
delimiters in markup languages, 252
descriptive markup languages, 252–253
designing programs, 92–93, 93
die function, 170, 352, 407
directives. See server-side includes
directories
chdir function, 348
chroot function, 349–350
closedir function, 350
mkdir function, 370
opendir function, 372
Perl directory functions, 239, 407
readdir function, 377
reading directories of log files, 238–243, 239, 242
rewinddir function, 239, 379
rmdir function, 380
seekdir function, 239, 381
setting directory permissions, 321–324, 322, 323
telldir function, 239, 390
write permission for users from the World Wide Web, 102
displaying
CGI environment variables in HTML documents, 72–82
display program explained, 75–76
each function, 76–77, 353
running the example, 77–80, 78, 79
sorting associative arrays, 81–82, 82
while statements, 76–77
writing the display program, 72–75
guest book entries, 174–181
the display program, 174–177, 178, 179
for statements, 179–180
localtime function, 180–181, 369
NULL characters, 77, 180, 410
overview of, 174–175
read function in a while loop, 178–179
do function, 352
document type definitions (DTDs), 253–257, 407. See also SGML
defining markup languages, 254–257
IETF (Internet Engineering Task Force) Level 2 and 3 DTDs, 253–254
Netscape’s Mozilla DTD, 254
dollar sign ($)
global variable ($!), 170, 408
in regular expressions, 132
scalars and, 23, 97
Domain Name Service (DNS), 60, 399
domain names, 305
registering, 398
dot (.)
directory notation in UNIX and Windows, 238
in regular expressions, 132
string concatenation operator, 226–227
double quote (“)
escaped double quote (||”), 20
in lists, 26
downloading
Ghostscript, 204–205
Perl, 13
Perl script for emulating server-side includes, 190
Sambar Web server, 39, 39
DTDs. See document type definitions
dump function, 353
dynamic Web pages, 194

E

each function, 76–77, 353
#echo server-side includes directive, 191, 194–196, 195
ed command in UNIX, 8
elements in SGML, 254, 256
else statements. See if statements
emulating server-side includes, 190
encoding
printable characters in URLs, 121–123, 410
URLs with GET method, 124–126, 126
encrypted passwords, 326–327, 328
ender code files
creating, 51–52
installing, 52–53
ending Perl scripts, 20–21, 21
environment variables, 30, 30, 66–82, 103–104, 407. See also CGI
common variables listed, 71
in counters, 103–104
displaying in HTML documents, 72–82
display program explained, 75–76
each function, 76–77, 353
running the example, 77–80, 78, 79
sorting associative arrays, 81–82, 82
while statements, 76–77
writing the display program, 72–75
setting, 69–70, 70
using, 66–68, 67, 69
eof function, 353–354
equal to operator (==), 105
error message display configuration using server-side includes, 191, 198–200, 199
escaped characters, 19–20
European Laboratory for Particle Physics (CERN), 190, 400–401, 406
eval function, 354
exclamation point (!)
in comments, 18
global variable ($!), 170, 408
not equal to operator (!=), 105
exec function, 354
#exec server-side includes directive, 191, 196–197, 320–321
exercises. See Sambar Web server
exit function, 355
exp function, 355
expressions. See regular expressions
extensions, 258–263. See also HTML
for applets, 260, 263
for frames, 258–259, 258, 259, 260–263, 262
external code, 51
extracting log file information, 217–219, 223–231
from IIS logs, 217–219, 218
with split function, 223–227, 225
from UNIX Common Log Format files, 227–231, 229

F

fcntl function, 355
file handles, 96–97, 407–408
getc function, 356–357
read function, 94–95, 100, 376
in quiz form example, 143–145, 145
in while loops, 178–179
stat function, 387
STDIN (standard input), 143–145, 145, 411
tell function, 390
truncate function, 391
file name extensions
.pl, 38
.pm, 169
File Transfer Protocol (FTP), 321
fileno function, 355–356
files, 94–101. See also log files; print function; read function
append operator (>>), 97, 98
close function, 94–96, 350
configuring file-size display with server-side includes, 191, 198–200, 199
creating password files, 328–330
eof function, 353–354
fcntl function, 355
#fsize and #flastmod server-side includes directives for getting file statistics, 191, 197–198, 408
hosts files, 409
comments in, 60–61
gethostbyaddr and gethostbyname functions, 308–310, 357–358
IP addresses and, 60–62, 61, 305–306
link function, 368
open function, 94–96, 371–372
overview of file handling functions, 94–95, 95
redirection operators (< >) for input and output, 97–98
rename function, 378
setting file permissions, 321–324, 322, 323
unlink function, 392
write function, 94–96, 100, 102, 395
filtering HTML code, shell commands, or URLs out of form input, 183–184, 183, 184
finding. See searching
firewalls, 306, 408
flags, 152, 408
#flastmod server-side includes directive, 191, 197–198, 408
flock function, 356
folders. See directories
<FONT> tag in HTML, 253, 260
for statements. See also conditional statements
in guest book example, 179–180
in log file extraction example, 236–238
foreach statements, 242–243
fork function, 356
forms, 114–134. See also guest books
example, 115–118, 116
GET method and, 117, 118–119, 124–126, 126
input types, 117–118, 409
POST method and, 117, 118–119
quiz forms, 138–145, 139. See also forms
complex polling example, 146–156, 149, 150
counters, 153–154
examples, 138–142, 139, 142
GET method, 143
if statements, 154–156
POST method, 143–145, 145
processing, 143, 145–146, 156–157
read function, 143–145, 145
saving instructions, 144
STDIN (standard input) file handle, 143–145, 145, 411
regular expressions, 9, 128–133, 230–231, 301, 346, 365, 380, 411
asterisk (*) in, 132
backslash (\) in, 132
caret (^) in, 132
components of, 131–133
difficulty of, 131
dollar sign ($) in, 132
hex function, 130–131, 365
in log file extraction example, 230–231
pack function, 130–131, 170–173, 373–374
parentheses ( ) in, 133
/PATTERN/ operator, 346
period character or dot (.) in, 132
plus sign (+) in, 132
quantifiers, 132
question mark (?) in, 132
special characters, 132–133
substitute operator (s), 130, 380
translation function (tr), 128–131, 129
security issues, 181–184
filtering out HTML code, shell commands, or URLs, 183–184, 183, 184
obscenities, 182
restricting the amount of input, 182
submitting, 118–120, 119, 120
URLs in, 120–127
ampersand (&) in, 121, 124
decoding query strings, 120, 126–127, 127
encoding printable characters in URLs, 121–123, 410
hexadecimal values in, 121, 123–124
percent sign (%) in, 121, 124
plus sign (+) in, 124
question mark (?) in, 121, 124
URL encoding with GET method, 124–126, 126
forward slash (/) in UNIX, 15
frames
automating URLs with, 107–109, 108, 109
frame extension to HTML, 258–259, 258, 259, 260–263, 262
Netscape Navigator versus Internet Explorer and, 258–259, 258, 259
Free Software Foundation (FSF), 201–202, 408
#fsize server-side includes directive, 191, 197–198
FTP (File Transfer Protocol), 321

G

Gates, Bill, 279
gateways, 29
generating PostScript code with Ghostscript, 201–204, 203
GET method in HTML, 57–58, 408
encoding URLs with, 124–126, 126
in forms, 117, 118–119
in quiz forms, 143
getc function, 356–357
getgrent function, 357
gethostbyaddr function, 308–310, 357
gethostbyname function, 308–310, 357–358
gethostent function, 358
getlogin function, 358
getnetbyaddr function, 358–359
getnetbyname function, 359
getnetent function, 359
getpeername function, 359
getpgrp function, 359–360
getppid function, 360
getpriority function, 360
getprotobyname function, 360
getprotobynumber function, 361
getprotoent function, 361
getpwent function, 361
getpwnam function, 361–362
getpwuid function, 362
getservbyname function, 362
getservbyport function, 362
getservent function, 362–363
getsocketname function, 363
getsockopt function, 363
Ghostscript, 201–205, 408. See also graphical access counter
downloading, 204–205
generating PostScript code, 201–204, 203
GIF format support, 205
global variable ($!), 170, 408
gmtime function, 363–364
goto function, 364–365
graphical access counter, 205–212. See also counters; Ghostscript
local function, 209–210, 369
making the access counter example graphical, 206–208, 209
pipe function, 211, 374
PostScript code, 209, 212
print function GS parameter, 210
program explanation, 209–212
variables, 210–211
greater than operator (>), 105
greater than or equal to operator (>=), 105
grep command in UNIX, 8
grep function, 365
GS parameter for print function, 210
guest books, 162–185, 288–293, 336–341, 408. See also forms
adding entries, 166–168, 168, 169
creating, 162–166, 163, 165
deleting entries, 336–341, 339
die function, 170, 352, 407
displaying entries, 174–181
the display program, 174–177, 178, 179
for statements, 179–180
localtime function, 180–181, 369
NULL characters, 77, 180, 410
overview of, 174–175
read function in a while loop, 178–179
logical OR operator (||), 170, 409
pack function, 130–131, 170–173, 373–374
reading and writing structured data, 170–171
require function, 169–170
scalar variables, 169
security issues, 181–184
filtering out HTML code, shell commands, or URLs, 183–184, 183, 184
obscenities, 182
restricting the amount of input, 182
time function, 174, 390
unpack function, 170, 173–174, 392

H

handles. See file handles
hardware for Web servers, 268–274
hard disk drives, 274
memory, 272–273
microprocessors, 269–272
multiprocessor computers, 271, 273
overview of, 268–269
hashing, 72, 408
header files, extending subroutines with, 53–54
headers, MIME headers in Perl scripts, 48–49
Hello World script example, 15–21
creating, 15
ending, 20–21, 21
newline character (||n), 19
overview of, 12
print function, 18–19, 24, 45
running, 15–17, 16
hellowww.pl example, 45–55
creating, 45–46
creating ender code files, 51–52
extending subroutines with header files, 53–54
installing ender code files, 52–53
MIME headers, 48–49
print statements, 50–51
require function, 50–55
running, 47, 47
subroutines, 49–50, 50, 52
underscore (_), 54–55
here operator (<<), 296–297
hex function, 130–131, 365
hexadecimal values, 121, 123–124, 408
hit counters. See counters
hosts files, 409
comments in, 60–61
gethostbyaddr and gethostbyname functions, 308–310, 357–358
IP addresses and, 60–62, 61, 305–306
HTML forms. See forms
HTML (Hypertext Markup Language), 4, 409. See also markup languages; SGML
adding boilerplate to HTML documents with #include server-side includes directive, 191, 192–194, 193
CGI (Common Gateway Interface) and, 56–58, 56, 58
comments, 189
creating database searches, 294–297, 295, 298
creating HTML code and displaying on Web servers, 45–55
creating ender code files, 51–52
creating HTML code, 45–46
extending subroutines with header files, 53–54
installing ender code files, 52–53
MIME headers, 48–49
print statements, 50–51
require function, 50–55
running, 47, 47
subroutines, 49–50, 50, 52
underscore (_), 54–55
filtering HTML code out of form input, 183–184, 183, 184
<FONT> tag, 253, 260
GET method, 57–58, 408
encoding URLs with, 124–126, 126
in forms, 117, 118–119
in quiz forms, 143
history of, 257
input types, 117–118, 409
limitations of, 26–27
Netscape extensions, 258–263
for applets, 260, 263
for frames, 258–259, 258, 259, 260–263, 262
POST method, 58, 410
in forms, 117, 118–119
in quiz forms, 143–145, 145
SGML (Standard Generalized Markup Language) and, 250, 252–253
table width settings, 165
<TEXTAREA> tag, 181–182
HTTP (Hypertext Transfer Protocol), 7, 7, 401, 409
CGI (Common Gateway Interface) and, 56–58, 56, 58
Secure-HTTP (S-HTTP), 326, 411
HTTP servers. See also Sambar Web server; Web servers
browser communications with, 56–57
CGI and, 29
log files, 217
setting up, 38–45
configuring Windows NT Registry, 40–44, 41
downloading Sambar Web server, 39, 39
Internet Information Server and, 40–41
overview of, 38
running Sambar Web server on Windows 95 or NT, 39, 39
on UNIX, 44–45

I

IETF (Internet Engineering Task Force) Level 2 and 3 document type definitions (DTDs), 253–254
if statements. See also conditional statements
in access counters, 104–106
in database searches, 293, 302
in quiz forms, 154–156
Image MIME type, 85
implementing
programs, 93
Web page password-protection, 330–334, 331, 332, 334
#include directive in C and C++, 51
#include server-side includes directive, 191, 192–194, 193
index function, 365
initializing associative arrays, 73–75
input with redirection operators (< >), 97–98
input types in HTML, 117–118, 409
installing
ender code files, 52–53
Internet Information Server, 40
Perl interpreter, 13–14
int function, 365–366
Internet, 409. See also World Wide Web
history of, 398–403
Defense Advanced Research Project Agency (DARPA), 399
the explosion, 400
online services and, 400
World Wide Web, 400–403, 402
logging in to UNIX and Windows NT systems from, 317–319, 318
Internet Engineering Task Force (IETF) Level 2 and 3 document type definitions (DTDs), 253–254
Internet Explorer, 258–259, 258, 259
Internet Information Server (IIS)
HTTP servers and, 40–41
IIS logs
making compatible with UNIX Common Log Format, 221–222, 222
retrieving information from, 217–219, 218
storing, 217
restricting access to Web server directories, 319–320, 319, 320
Internet ports, 57
Internet programming, 303–311
Internet addresses, hosts files, firewalls and, 305–306, 408
resolving Internet addresses with Perl, 306–311, 308
TCP/IP networking functions, sockets libraries and, 303–305
uses for, 311
Internet service providers (ISPs), 409
maintaining Web sites on, 46
InterNIC, 398
interpreted languages, 11–12
interprocess communication (IPC), 70
intruders. See security
ioctl function, 366
IP addresses, 409. See also addresses
and controlling counters, 103–106
hosts files and, 60–62, 61, 305–306
in log files, 219, 235
programming for, 305–306
resolving with Perl, 306–311, 308
IPC (interprocess communication), 70
ISPs. See Internet service providers

J

Java, 4–5, 409
Java applets, 5, 406
applet extension to HTML, 260, 263
JavaScript, 5–6, 6
as a CGI language, 34
join function, 366

K

keys function, 76, 366–367
kill function, 367
ksh command in UNIX, 8

L

languages. See also HTML; Perl; SGML
C and C++ languages, 406
argv lists, 293
as CGI programming languages, 31–32, 31
#include directive, 51
UNIX and C language, 9–10, 10
CGI programming languages, 31–34
ActiveX controls, 34
C and C++, 31–32, 31
JavaScript, 5–6, 6, 34
proprietary CGI methods, 34
shell scripts, 33–34
Visual Basic, 32–33, 33
compiled versus interpreted languages, 11–12
Java, 4–5, 409
markup languages, 250–252, 251
defining in document type def-initions (DTDs), 254–257
descriptive markup languages, 252–253
procedural markup languages, 252
metalanguages, 250
proprietary languages, 5–6, 6
Visual Basic Script, 5–6, 6
last function, 367
Law of Data, Parkinson’s, 274
lc function, 367–368
lcfirst function, 368
length function, 368
less than operator (<), 105
less than or equal to operator (<=), 105
link function, 368
linking regular expressions with logical AND operator (&&), 301
Linux operating system, 270
listen function, 368–369
lists, 22, 24–26, 293, 409
ARGV lists, 293
double quote (“) and single quote (’) in, 26
naming, 24
at sign (@) in, 24–25
strings in, 25–26
syntax of, 24–25
local function, 209–210, 369
localtime function, 180–181, 369
log files, 216–245
decoding, 217
extracting information, 217–219, 223–231
from IIS logs, 217–219, 218
with split function, 223–227, 225
from UNIX Common Log Format files, 227–231, 229
HTTPD server logs, 217
IIS logs
extracting information from, 217–219, 218
making compatible with UNIX Common Log Format, 221–222, 222
storing, 217
IP addresses in, 219, 235
for monitoring Web page activity, 231–245
counting who accesses your Web page and how often, 232–238, 234
overview of, 231–232
putting access counters in Web pages, 244–245, 245
reading directories of log files, 238–243, 239, 242
NCSA server logs, 217, 221
Sambar server logs, 217
UNIX Common Log Format, 219–221, 220
extracting information, 227–231, 229
making IIS logs compatible with, 221–222, 222
log function, 369
logging in to UNIX and Windows NT systems from the Internet, 317–319, 318
logical AND operator (&&), 301, 409
logical OR operator (||), 155, 170, 409
loopback addresses, 61
lowercase. See case
lstat function, 370

M

man command in UNIX, 8
map function, 370
markup languages, 250–252, 251. See also HTML; SGML
defining in document type definitions (DTDs), 254–257
descriptive markup languages, 252–253
procedural markup languages, 252
memory
bus architecture and, 273
dump function, 353
virtual memory, 272
Web server requirements, 272–273
message display configuration using server-side includes, 191, 198–200, 199
Message MIME type, 85
metalanguages, 250
microprocessors
Moore’s Law, 270
multiprocessor computers, 271, 273
Web server requirements, 269–272
Microsoft Internet Explorer, 258–259, 258, 259
Microsoft Windows 95
multitasking, 69, 271, 410
running Sambar Web server on, 39, 39
security, 281–282
as a Web server operating system, 271, 274, 277, 281–282
as Web server software, 284
Microsoft Windows NT
configuring Registry for HTTP servers, 40–44, 41
logging in to Windows NT systems from the Internet, 317–319, 318
logon passwords, 318–319
mounting remote shared volumes, 318
multitasking, 69, 271, 410
restricting access to Web server directories, 319–320, 319, 320
running Sambar Web server on, 39, 39
security, 280–281
services, 42
setting file and directory permissions, 321–324, 323
taking ownership, 322
versus UNIX, 279
as a Web server operating system, 270–271, 274, 277, 278–281, 280
as Web server software, 284
Microsoft Windows NT Server, overview of, 279–280
Microsoft Windows NT Workstation
connection restrictions, 273
overview of, 279–280
MIME (Multipurpose Internet Mail Extensions), 45, 410
CGI (Common Gateway Interface) and, 58–59, 59
MIME headers in Perl scripts, 48–49
MIME types, 82–85
Application type, 83
Audio and Video types, 84
Image type, 85
Message type, 85
Multipart type, 85, 86
Text type, 85
MIME-encoded files, 84
mkdir function, 370
Moore’s Law, 270
mounting remote shared Windows NT volumes, 318
Mozilla document type definitions (DTDs), 254
msgctl, msgget, msgrcv, and msgsnd functions, 370
Multipart MIME type, 85, 86
multiprocessor computers, 271, 273
multitasking, 69, 271, 410
my function, 370–371

N

naming lists, 24
NCSA servers, 410. See also Web servers
log files, 217, 221
Web server software, 283
Netscape
extensions, 258–263
for applets, 260, 263
for frames, 258–259, 258, 259, 260–263, 262
Mozilla document type definitions (DTDs), 254
Netscape Navigator versus Internet Explorer, 258–259, 258, 259
Secure Sockets Layer (SSL), 324–326, 325, 411
newline character (||n), 19
next function, 371
NOBR Netscape HTML extension, 260
not equal to operators (!= or <=>), 105
NULL values, 77, 180, 410
number sign (#)
as comment character in hosts files, 60–61
as comment character in Perl, 15, 18
in server-side includes directives, 189
numbers in strings, 68

O

obscenities in form input, 182
oct function, 371
online services, 400
open function, 94–96, 371–372
opendir function, 372
operating systems for Web servers, 274–282, 410. See also Microsoft Windows; UNIX
Linux, 270
overview of, 274–275
UNIX, 269–270, 274, 275–278, 276
Windows 95, 271, 274, 277, 281–282
Windows NT, 270–271, 274, 277, 278–281, 280
operators
arithmetic operators, 99
here operator (<<), 296–297
logical OR operator (||), 155, 170, 409
/PATTERN/ operator, 346
relational operators, 105–106
substitute operator (s), 130, 380
translation operator (tr), 128–131, 129, 391
OR operator (||), 155, 170
ord function, 372
output with redirection operators (< >), 97–98

P

pack function, 130–131, 170–173, 373–374
parameters, 18
parent applications, 69–70, 70
parentheses ( )
in regular expressions, 133
in while statements, 77
Parkinson’s Law of Data, 274
passwords. See also security
getpwent function, 361
getpwnam function, 361–362
getpwuid function, 362
password-protecting Web pages, 326–335
creating password files, 328–330
implementing password-protection, 330–334, 331, 332, 334
reading and writing encrypted passwords, 326–327, 328
uses for, 334–335, 335
/PATTERN/ operator, 346
percent sign (%)
in associative arrays, 72
in URLs, 121, 124
period (.)
directory notation in UNIX and Windows, 238
in regular expressions, 132
string concatenation operator, 226–227
Perl, 4, 8–9, 410
case sensitivity in, 23
CGI (Common Gateway Interface) and, 26–28, 27, 28
compiling Perl source code, 14
downloading, 13
history of, 8–10, 10, 11
HTTP and, 7, 7
as an interpreted language, 11–12
Perl interpreter, 13–15
installing, 13–14
starting, 14–15
regular expressions, 9
special characters, 19–20
UNIX and, 6–10, 10, 11
World Wide Web and, 26–28, 28
Perl scripts, 12, 13
for emulating server-side includes, 190
Hello World example, 15–21
creating, 15
ending, 20–21, 21
newline character (||n), 19
overview of, 12
print function, 18–19, 24, 45
running, 15–17, 16
hellowww.pl example, 45–55
creating, 45–46
creating ender code files, 51–52
extending subroutines with header files, 53–54
installing ender code files, 52–53
MIME headers, 48–49
print statements, 50–51
require function, 50–55
running, 47, 47
subroutines, 49–50, 50, 52
underscore (_), 54–55
how Perl scripts run, 16–17, 17
personalizing Web pages to visitors, 191, 194–196, 195
pipe function, 211, 374
.pl files, 38
plus sign (+)
in regular expressions, 132
in URLs, 124
.pm files, 169
polling. See quiz forms
pop function, 374
ports, Internet ports, 57
POST method in HTML, 58, 410
in forms, 117, 118–119
in quiz forms, 143–145, 145
PostScript code
generating with Ghostscript, 201–204, 203
in graphical access counter, 209, 212
pound sign (#)
as comment character in hosts files, 60–61
as comment character in Perl, 15, 18
in server-side includes directives, 189
print function, 375
in cgienv.pl example, 80
in database searches, 297
for files, 94–95, 99–101
GS parameter, 210
in hellowww.pl example, 50–51
printf function, 375–376
printing to the screen, 18–19, 24, 45
printing to Web servers in HTML, 45–49, 47
sprintf function, 386
printable characters in URLs, 121–123, 410
procedural markup languages, 252
processing quiz forms, 143, 145–146, 156–157
processors. See microprocessors
programming languages. See languages
proprietary CGI methods, 34
proprietary languages, 5–6, 6
protocols
FTP (File Transfer Protocol), 321
getprotobyname function, 360
getprotobynumber function, 361
getprotoent function, 361
HTTP (Hypertext Transfer Protocol), 7, 7, 401, 409
CGI (Common Gateway Interface) and, 56–58, 56, 58
Secure-HTTP (S-HTTP), 326, 411
TCP/IP, 411
history of, 399
hosts files and, 60–62, 61
networking functions, 303–305
Telnet, 321
push function, 376

Q

quantifiers in regular expressions, 132
query strings in URLs, 120, 126–127, 127
question mark (?)
in regular expressions, 132
in URLs, 121, 124
quiz forms, 138–145, 139. See also forms
complex polling example, 146–156, 149, 150
counters, 153–154
examples, 138–142, 139, 142
GET method, 143
if statements, 154–156
POST method, 143–145, 145
processing, 143, 145–146, 156–157
read function, 143–145, 145
saving instructions, 144
STDIN (standard input) file handle, 143–145, 145, 411
quotation marks. See double quote; single quote

R

rand function, 376
read function, 94–95, 100, 376
in quiz form example, 143–145, 145
in while loops, 178–179
readdir function, 377
reading
encrypted passwords, 326–327, 328
structured data, 170–171
readlink function, 377
records, 288
recv function, 377
redirection operators (< >), 97–98
registering domain names, 398
regular expressions, 9, 128–133, 230–231, 301, 346, 365, 380, 411
asterisk (*) in, 132
backslash (\) in, 132
caret (^) in, 132
components of, 131–133
difficulty of, 131
dollar sign ($) in, 132
hex function, 130–131, 365
linking with logical AND operator (&&), 301
in log file extraction example, 230–231
pack expression, 130–131, 170–173, 373–374
parentheses ( ) in, 133
/PATTERN/ operator, 346
period character or dot (.) in, 132
plus sign (+) in, 132
quantifiers, 132
question mark (?) in, 132
special characters, 132–133
substitute operator (s), 130, 380
translation function (tr), 128–131, 129
relational operators, 105–106
rename function, 378
require function, 378
in cgienv.pl example, 75–76, 78
in guest book program, 169–170
in hellowww.pl example, 50–55
reset function, 378
resolving Internet addresses with Perl, 306–311, 308
restricting
access to Web server directories, 319–320, 319, 320
the amount of input into forms, 182
return function, 378–379
return-value convention, 79
reverse function, 379
rewinddir function, 239, 379
Rich Text Format, 251–252, 251
rindex function, 379
rmdir function, 380
running
CGI applications, 324
Hello World script example, 15–17, 16
hellowww.pl example, 47, 47
Perl scripts, 16–17, 17
programs on Web servers with #exec server-side includes directive, 191, 196–197, 320–321
Sambar Web server on Windows 95 or NT, 39, 39

S

s (substitution operator), 130, 380
Sambar Web server, 39, 60–63, 411. See also Web servers
downloading, 39, 39
exercises
counters, 110, 246
creating home pages, 86–87
creating links, 285
database searches, 312
forms, 133
frames, 110, 264
graphical counters, 213
guest book, 185
log files, 246
opening Sambar server Web page, 62–63
quiz forms, 157
server-side includes, 213
Web site security, 343
log files, 217, 246
restricting access to Web server directories, 319–320, 319, 320
running on Windows 95 or NT, 39, 39, 62
security, 282
TCP/IP protocol, hosts files and, 60–62, 61
on Windows 95 and NT, 284
scalars, 22–24, 23, 411. See also variables
dollar sign ($) and, 23, 97
in guest books, 169
scalar function, 380
SCRIPT Netscape HTML extension, 260
scripts. See Perl scripts
searching
databases, 288–303
converting guest books into command-line searchable databases, 288–293, 289, 292
creating database searches in HTML, 294–297, 295, 298
searching on multiple fields, 298–303, 300, 302
wildcards in, 299, 301
for security holes in your system, 316–317
Secure Sockets Layer (SSL), 324–326, 325, 411
Secure-HTTP (S-HTTP), 326, 411
security, 181–184, 280–282, 306, 316–343
finding security holes in your system, 316–317
firewalls, 306, 408
in forms, 181–184
filtering out HTML code, shell commands, or URLs, 183–184, 183, 184
obscenities, 182
restricting the amount of input, 182
FTP, Telnet and, 321
logging in to UNIX and Windows NT systems from the Internet, 317–319, 318
password-protecting Web pages, 326–335
creating password files, 328–330
implementing password-protection, 330–334, 331, 332, 334
reading and writing encrypted passwords, 326–327, 328
uses for, 334–335, 335
passwords
getpwent function, 361
getpwnam function, 361–362
getpwuid function, 362
restricting access to Web server directories, 319–320, 319, 320
running CGI applications, 324
in Sambar Web server, 282
Secure Sockets Layer (SSL), 324–326, 325, 411
Secure-HTTP (S-HTTP), 326, 411
server-side includes #exec directive system calls and, 320–321
setting file and directory permissions, 321–324, 322, 323
Web site security, 335–343
creating a maintenance tool from guest book editor program, 341–343
deleting guest book entries, 336–341, 339
overview of, 335–336
in Windows 95, 281–282
in Windows NT, 280–281
sed command in UNIX, 8, 9
seek function, 380–381
seekdir function, 239, 381
select function, 381
selecting
hardware for Web servers, 268–274
hard disk drives, 274
memory, 272–273
microprocessors, 269–272
multiprocessor computers, 271, 273
overview of, 268–269
operating systems for Web servers, 274–282
Linux, 270
operating systems defined, 410
overview of, 274–275
UNIX, 269–270, 274, 275–278, 276
Windows 95, 271, 274, 277, 281–282
Windows NT, 270–271, 274, 277, 278–281, 280
Web browsers to support, 282, 284
Web server software, 282–284
overview of, 282–283
UNIX Apache servers, 283, 406
UNIX NCSA servers, 217, 221, 283, 410
Windows NT and 95 servers, 284
semctl, semget, and semop functions, 382
semicolon (;) in Perl, 19
send function, 382
servers. See Web servers
server-side includes (SSI), 188–199, 411
#config directives for date and time, file-size statistics, and error message display, 191, 198–200, 199
directives listed, 191
#echo directive for personalizing Web pages to visitors, 191, 194–196, 195
#exec directive for running programs on Web servers, 191, 196–197, 320–321
#fsize and #flastmod directives for getting file statistics, 191, 197–198, 408
#include directive for adding boilerplate to HTML documents, 191, 192–194, 193
Perl script for emulating server-side includes, 190
Web servers and, 191–192, 192
services
getservbyname function, 362
getservbyport function, 362
getservent function, 362–363
in Windows NT, 42
setpgrp function, 382
setpriority function, 382–383
setsockopt function, 383
setting file and directory permissions, 321–324, 322, 323
setting up HTTP servers, 38–45. See also Web servers
configuring Windows NT Registry, 40–44, 41
downloading Sambar Web server, 39, 39
Internet Information Server and, 40–41
overview of, 38
running Sambar Web server on Windows 95 or NT, 39, 39
on UNIX, 44–45
SGML (Standard Generalized Markup Language), 250–257, 411
descriptive markup languages and, 252–253
document type definitions (DTDs), 253–257, 407
defining markup languages, 254–257
IETF (Internet Engineering Task Force) Level 2 and 3 DTDs, 253–254
Netscape’s Mozilla DTD, 254
elements, 254, 256
HTML and, 250, 252–253
markup languages explained, 250–252, 251
sh command in UNIX, 8
shell commands, filtering out of form input, 183–184, 183, 184
shell scripts for CGI programming, 33–34
shift function, 383
shmctl, shmget, shmread, and shmwrite functions, 383
S-HTTP protocol, 326, 411
shutdown function, 383–384
sin function, 384
single quote (’) in lists, 26
slash (/) in UNIX, 15
sleep function, 384
sockets
accept function, 346
bind function, 347
close function, 94–96, 350
connect function, 350
getpeername function, 359
getsocketname function, 363
getsockopt function, 363
listen function, 368–369
recv function, 377
Secure Sockets Layer (SSL), 324–326, 325, 411
send function, 382
setsockopt function, 383
shutdown function, 383–384
socket function, 384–385
socketpair function, 385
sockets libraries, 303–305
sort function, 81–82, 82, 385
special characters. See also Symbols section of the index
in Perl, 19–20
in regular expressions, 132–133
splice function, 385–386
split function, 386
decoding URL query strings, 126–127
extracting log file information, 223–227, 225
sprintf function, 386
sqrt function, 386
srand function, 386–387
SSI. See server-side includes
SSL (Secure Sockets Layer), 324–326, 325, 411
standard input (STDIN) file handle, 143–145, 145, 411
standard output (stdout), 16–17, 17, 45, 99, 411
starting Perl interpreter, 14–15
stat function, 387
STDIN (standard input) file handle, 143–145, 145, 411
strings, 18, 22
in lists, 25–26
numbers in, 68
string concatenation operator (.), 226–227
study function, 388
submitting forms, 118–120, 119, 120
subroutines, 49–50, 50
extending with header files, 53–54
in hellowww.pl example, 52
substitute operator (s), 130, 380
substr function, 388
super-users in UNIX, 318
symbols. See special characters; Symbols section of the index
symlink function, 388
syntax of lists, 24–25
syscall function, 388–389
sysread function, 389
system function, 389
systems, 91
syswrite function, 389–390

T

table width settings, 165
TCP/IP protocol, 411. See also protocols
history of, 399
hosts files and, 60–62, 61
networking functions, 303–305
tell function, 390
telldir function, 239, 390
Telnet program, 321
template formats for pack function, 170–173
terminating conditions, 179
text. See strings
Text MIME type, 85
<TEXTAREA> tag in HTML, 181–182
time
configuring display with server-side includes, 191, 198–200, 199
gmtime function, 363–364
localtime function, 180–181, 369
time function, 174, 390
times function, 391
in UNIX Common Log Format, 221
utime function, 393
tools, 54
translation operator (tr), 128–131, 129, 391
truncate function, 391

U

umask function, 391–392
undef function, 392
underscore (_) in Perl, 54–55
UNIX, 7–8
Apache Web server software, 283, 406
BSD (Berkeley Systems Development) UNIX, 303–304
C language and, 9–10, 10
commands and utilities, 8
Common Log Format, 219–221, 220, 407. See also log files
extracting information, 227–231, 229
making IIS logs compatible with, 221–222, 222
daemons, 42
forward slash (/) in, 15
httpd.conf files, 45
logging in to UNIX systems from the Internet, 317–319, 318
logon passwords, 318–319
multitasking, 69, 271, 410
NCSA Web server software, 217, 221, 283, 410
Perl and, 6–10, 10, 11
regular expressions, 9
restricting access to Web server directories, 319–320, 319, 320
setting file and directory permissions, 321–324, 322, 323
setting up HTTP servers on, 44–45
sockets library, 303–305
srm.conf files, 44
super-users, 318
as a Web server operating system, 269–270, 274, 275–278, 276
versus Windows NT, 279
X-Windows interface, 276
unlink function, 392
unpack function, 170, 173–174, 392
unshift function, 392–393
uppercase. See case
URLs (Uniform Resource Locators), 47, 120–121, 121, 411
automating with frames, 107–109, 108, 109
filtering out of form input, 183–184, 183, 184
in forms, 120–127
ampersand (&) in, 121, 124
decoding query strings, 120, 126–127, 127
encoding printable characters in URLs, 121–123, 410
hexadecimal values in, 121, 123–124
percent sign (%) in, 121, 124
plus sign (+) in, 124
question mark (?) in, 121, 124
URL encoding with GET method, 124–126, 126
utilities in UNIX, 8
utime function, 393

V

values function, 76, 393
variables, 411
CGI environment variables, 30, 66–82, 103–104, 407
common variables listed, 71
in counters, 103–104
displaying in HTML documents, 72–82
setting, 69–70, 70
using, 66–68, 67, 69
displaying CGI environment variables in HTML documents, 72–82
display program explained, 75–76
each function, 76–77, 353
running the example, 77–80, 78, 79
sorting associative arrays, 81–82, 82
while statements, 76–77
writing the display program, 72–75
global variable ($!), 170, 408
in graphical access counter, 210–211
local function, 209–210, 369
my function, 370–371
in Perl, 21–22
reset function, 378
scalars, 22–24, 23, 411
dollar sign ($) and, 23, 97
in guest books, 169
scalar function, 380
vec function, 393
vi command in UNIX, 8
Video MIME type, 84
virtual memory, 272
Visual Basic, 32–33, 33
Visual Basic Script, 5–6, 6
volumes, mounting remote shared Windows NT volumes, 318

W

wait function, 394
waitpid function, 394
Wall, Larry, 8, 49, 101, 152
wantarray function, 394
warn function, 394–395
WBR Netscape HTML extension, 260
Web browsers, 401–403, 402, 406. See also World Wide Web
communications with HTTP servers, 56–57
deciding which to support, 282, 284
Java applets and, 5
Web pages. See also Web sites
dynamic Web pages, 194
monitoring activity, 231–245
counting who accesses your Web page and how often, 232–238, 234
overview of, 231–232
putting access counters in Web pages, 244–245, 245
reading directories of log files, 238–243, 239, 242
password-protecting, 326–335
creating password files, 328–330
implementing password-protection, 330–334, 331, 332, 334
reading and writing encrypted passwords, 326–327, 328
uses for, 334–335, 335
personalizing to visitors, 194–196, 195
Web servers, 268–285. See also HTTP servers; log files; Sambar Web server
creating HTML code and displaying on, 45–55
creating ender code files, 51–52
creating HTML code, 45–46
extending subroutines with header files, 53–54
installing ender code files, 52–53
MIME headers, 48–49
print statements, 50–51
require function, 50–55
running, 47, 47
subroutines, 49–50, 50, 52
underscore (_), 54–55
HTTP server setup, 38–45
configuring Windows NT Registry, 40–44, 41
downloading Sambar Web server, 39, 39
Internet Information Server and, 40–41
overview of, 38
running Sambar Web server on Windows 95 or NT, 39, 39
on UNIX, 44–45
HTTP servers
browser communications with, 56–57
CGI and, 29
log files, 217
NCSA servers, 410
log files, 217, 221
Web server software, 283
restricting access to directories, 319–320, 319, 320
running programs on with #exec server-side includes directive, 191, 196–197, 320–321
selecting hardware, 268–274
hard disk drives, 274
memory, 272–273
microprocessors, 269–272
multiprocessor computers, 271, 273
overview of, 268–269
selecting operating systems, 274–282
Linux, 270
operating systems defined, 410
overview of, 274–275
UNIX, 269–270, 274, 275–278, 276
Windows 95, 271, 274, 277, 281–282
Windows NT, 270–271, 274, 277, 278–281, 280
selecting Web server software, 282–284
overview of, 282–283
UNIX Apache servers, 283, 406
UNIX NCSA servers, 217, 221, 283, 410
Windows NT and 95 servers, 284
server-side includes (SSI) and, 191–192, 192
supporting Web browsers, 282, 284
Web sites. See also Web pages
on Internet service providers, 46
security, 335–343
creating a maintenance tool from guest book editor program, 341–343
deleting guest book entries, 336–341, 339
overview of, 335–336
whereis command in UNIX, 8
while statements, 76–77. See also conditional statements
in log file extraction example, 230
read function in a while loop, 178–179
wildcards in database searches, 299, 301
Winsock API, 304–305, 412
World Wide Web, 412. See also Internet; Web browsers
history of, 400–403
Perl, CGI (Common Gateway Interface) and, 26–29, 27, 28
wrappers, 101–102, 103
write function, 94–96, 100, 102, 395
writing
encrypted passwords, 326–327, 328
structured data, 170–171

X

X-Windows interface for UNIX, 276


Table of Contents


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.