3145 index final - perl · 2003-01-23 · cpan (comprehensive perl archive), 322-31 ppm (perl...

18
Index Symbols -- operator, 63-64 ! Boolean operator, 54 != comparison operator, 52, 120 # (sharp), 28 #! symbol, 27 -w switch, 27-28 $", 534 $ (dollar), 60 $- variable, 534 $' variable, 532 $! variable, 180-81, 535 $# variable, 534 $$ variable, 535 $% variable, 534 $& variable, 532 $( variable, 535 $) variable, 535 $, variable, 533 $. variable, 533 $/ variable, 186, 533 $: variable, 534 $? variable, 534 $@ variable, 534 $\ variable, 533 $] variable, 535 $^ variable, 534 $^E variable, 535 $^L variable, 534 $^O variable, 535 $^T variable, 535 $^W variable, 535 $^X variable, 535 $_ (default) variable, 67, 531 $` variable, 532 $| variable, 533, 534 $~ variable, 534 $+ variable, 532 $< variable, 535 $= variable, 534 $> variable, 535 $0 variable, 535 $1, $2, ... variables, 532 $ARGV variable, 183, 531 % (percent), 104 %ENV variable, 384-87, 535 %INC variable, 536 %SIG variable, 535 & bitwise operator, 49-50 && Boolean operator, 53 ( ) (brackets), lists, 76 ; (semicolon), 29, 281 @ (at), 86 @- array, 533 @_ array, 260-61, 531 @+ array, 532 @ARGV array, 133-34, 531 @INC array, 298, 312, 536 @ISA array, AnyDBM_File module, 444 \ (backslash), metacharacters, 156-58 [ ] (square brackets) references to arrays, 220 ^ bitwise operator, 50 _ (underscore) numbers, 38 variable names, 67 { } (curly brackets) blocks, 30, 281-82 dereferencing, 222, 227 hashes, 106 references to hashes, 220 | bitwise operator, 50 || Boolean operator, 54, 265 ~ bitwise operator, 50-51 ++ operator, 63-64 < > diamond operator, 181-82 < comparison operator, 52, 120 <= comparison operator, 52

Upload: others

Post on 20-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Index

Symbols-- operator, 63-64! Boolean operator, 54!= comparison operator, 52, 120# (sharp), 28#! symbol, 27

-w switch, 27-28

$", 534$ (dollar), 60$- variable, 534$' variable, 532$! variable, 180-81, 535$# variable, 534$$ variable, 535$% variable, 534$& variable, 532$( variable, 535$) variable, 535$, variable, 533$. variable, 533$/ variable, 186, 533$: variable, 534$? variable, 534$@ variable, 534$\ variable, 533$] variable, 535$^ variable, 534$^E variable, 535$^L variable, 534$^O variable, 535$^T variable, 535$^W variable, 535$^X variable, 535$_ (default) variable, 67, 531$` variable, 532$| variable, 533, 534$~ variable, 534$+ variable, 532

$< variable, 535$= variable, 534$> variable, 535$0 variable, 535$1, $2, ... variables, 532$ARGV variable, 183, 531% (percent), 104%ENV variable, 384-87, 535%INC variable, 536%SIG variable, 535& bitwise operator, 49-50&& Boolean operator, 53( ) (brackets), lists, 76; (semicolon), 29, 281@ (at), 86@- array, 533@_ array, 260-61, 531@+ array, 532@ARGV array, 133-34, 531@INC array, 298, 312, 536@ISA array, AnyDBM_File module, 444\ (backslash), metacharacters, 156-58[ ] (square brackets)

references to arrays, 220

^ bitwise operator, 50_ (underscore)

numbers, 38variable names, 67

{ } (curly brackets)blocks, 30, 281-82dereferencing, 222, 227hashes, 106references to hashes, 220

| bitwise operator, 50|| Boolean operator, 54, 265~ bitwise operator, 50-51++ operator, 63-64< > diamond operator, 181-82< comparison operator, 52, 120<= comparison operator, 52

<=> comparison operator

632

<=> comparison operator, 53<> (empty diamond), 183= assignment operator, 60, 61-62

multiple assignments, 64-65precedence, 62

== comparison operator, 51-52, 120=> operator, 105> comparison operator, 52, 120-> dereferencing operator, 228-30>= comparison operator, 52

Numbers-0 switch, 299, 579$0 variable, 535$1, $2, ... variables, 532

A-a switch, 298-99, 579abs function, 540abstraction

See "encapsulation".

accept function, 540accept method, IO::Socket module, 499accessor methods, 351ActivePerl, 380add method, IO::Select module, 498ADO (Active Data Objects), 454alarm function, 541aliases, 131-32

@_ variable, 260-61

ALRM signal, 491anchors, regular expressions, 153-54and Boolean operator, 54, 123anonymous references, 218, 220-21

arrays, 220hashes, 220reference counts, 231

AnyDBM_File module, 443-44, 447, 569@ISA array, 444

Apache web server, 378-79Apache::Session module, 418-20arguments, functions, 30-31arguments, subroutines

See "parameters".

@ARGV array, 133-34, 183, 531$ARGV variable, 183, 531arithmetic operators, 46-48

++, -- operators, 63-64precedence, 47-48

arrays, 86-104assignments, 87-91context, 89-90

conversion to hashes, 105-6elementsaccessing an element, 91-94accessing many elements, 94-96adding an element, 90-91references to elements, 224

for loops, 96-99functions, 99matrices, 231-32passing arrays as parameters, 263-64references to arrays, 220dereferencing, 222-24

references to subroutines, 268reverse function, 99slices, 94-96

ASCII, 31ord function, 57-58

assignments, 61-62arrays, 87-91context, 89-90

literal lists, 83multiple assignments, 64-65

associative arraysSee "hashes".

atan2 function, 541attributes, 338, 347-48, 349-51

class attributes, 355-58get/set methods, 338, 354-55

attributes module, 567attrs module, 567AutoLoader module, 569AutoSplit module, 569autouse module, 567autovivification, 232-36available_drivers method, DBI module, 453

B\b metacharacter, 157-58B module, 569back whacking, 42backreferences, 162-63, 176backtick quoting, 490barewords, 41, 283base module, 567BEGIN subroutine, 312Benchmark module, 318-20, 569Math::BigFloat module, 506-10, 574Math::BigInt module, 506-10, 574binary data, 196-97binary system, 33, 39-41, 49

bitwise operators, 49-51

classes

633

bind function, 541bind_col method, DBI module, 480bind_columns method, DBI module, 481binmode function, 197, 541bits, 33bitwise operators, 49-51bless function, 345-47, 541blib module, 568blocking, sockets, 498blocks, 30Boolean operators, 53-55, 123-24

not operator, 54, 123precedence, 54

Boolean values, 51, 119bsd-db databases, 434buffering, 199-200bugs, 34, 141-43

barewords, 283debugging, 300-302defensive programming, 302-4error messages, 280-83"it doesn't work", 142logic errors, 280missing commas, 283missing open/close brackets, 281-82missing semicolons, 281Perl debugger, 301-2regular expressions, 171-72runaway strings, 282-83syntax errors, 280, 281-83Windows 2000, 34

Bundle::libnet module, 331Bundle::LWP module, 330-31bundles, 329-31bytecode, 21ByteLoader module, 569bytes, 33

CC programming language, 520-21-c switch, 294, 579-C switch, 579caching, subroutines, 252-53callbacks, subroutines, 267caller function, 253, 541caller module, 568can_read method, IO::Select module, 498can_write method, IO::Select module, 498Carp module, 570CGI::Carp module, 420-21, 570CGI (Common Gateway Interface), 377-431

%ENV variable, 384-87

ActivePerl, 380cookies, 415-18debugging, 420-22execution environment, 392HTML, 382-84, 392-405forms, 390-92, 404-5, 407-9headers, 400-402

HTTPheaders, 384-85, 398-400methods, 388-89, 390-92variables, 385-87

redirection, 411-12scripts, 381-422interactive scripts, 389-420

security, 422-30external programs, 423-26tainted variables, 426-27

server configuration, 377-81Apache, 378-79IIS, 380, 381PWS, 380-81

server push, 412-15sessions, 418-20state, 409-11URLs, 388-89, 405-6wrappers, 429

CGI module, 398-406, 570header method, 398-400new method, 409param method, 390-91save method, 409self_url method, 405-6start_html method, 400-402url method, 405-6

CGI::Carp module, 420-21, 570CGI::Cookie module, 415-18, 570

cookie method, 416-17

CGI::Pretty module, 403-4, 570CGI::Push module, 412-15, 570cgi-bin directory, Apache, 379character classes, 155-57

POSIX, 158Unicode, 158

charnames module, 568chdir function, 541child processes, 493CHLD signal, 494chmod function, 541chomp function, 541chop function, 542chown function, 542chr function, 542chroot function, 542classes, 339, 345-63

attributes, 338, 347-48, 349-51class attributes, 355-58

inheritance, 340-41, 364-68

classes (continued)

634

classes (continued)instances, 339methods, 338, 339, 351-55constructors, 341, 348-51DESTROY method, 341, 362get/set methods, 338, 354-55object vs class methods, 353-54private methods, 358-60utility methods, 360-61

objects, 337subclasses, 340superclasses, 340

clients, 496-97, 498close function, 542closedir function, 542cmp comparison operator, 58code

See "source code".

I18N::Collate module, 573columns, tables, databases, 480-84command lines, 5comments, 28-29, 304Common Gateway Interface

See "CGI".

comparison operatorsnumbers, 51-53, 120strings, 57-59, 121-22

compiled code, 20-21Math::Complex module, 512-13, 574Comprehensive Perl Archive Network

See "CPAN".

concatenation operator, 55conditions, 119Config module, 570connect function, 542connect method, DBI module, 460-64constant module, 568constants, 37constructors, 341, 348-51

inheritance, 349

context, subroutines, 253-54cookie method, CGI::Cookie module, 416-17CGI::Cookie module, 415-18, 570cookies, 415-18core modules, 22cos function, 542CPAN (Comprehensive Perl Archive), 322-31

PPM (Perl Package Manager), 323submitting a module to CPAN, 331

CPAN module, 326-29, 570CREATE TABLE statement, SQL, 468-69crypt function, 513-15, 542cryptography, 513-18

public key cryptography, 515-18

currency converter example, 69-71CVS files, 455Cwd module, 570

D\d metacharacter, 156\D metacharacter, 156-d switch, 579-D switch, 580data

binary data, 196-97reference counts, 230-31references, 217-41anonymous references, 218, 220-21dereferencing, 222-24, 227modifying data, 225-26

data structures, 231-40autovivification, 232-36linked lists, 239-40matrices, 231-32passing data structures as parameters, 263trees, 236-39traversing a tree, 238-39

data typesbarewords, 41floating-point numbers, 39integers, 38-39strings, 41-44

Data::Dumper module, 445, 446, 571data_sources method, DBI module, 454database drivers, 450, 452-54Database Interface

See "DBI".

Database ManagerSee "DBM".

databases, 433-85checking a database, 436closing a database, 437connecting to a database, 460-64creating a database, 437disconnecting from a database, 464-65emptying a database, 437entries, 437-38deleting an entry, 484reading an entry, 438

MySQL, 456-60opening a database, 435-36records, 450, 478-80relational databases, 450serializing modules, 445servers, 454-56single values, 480tables, 450, 467-75columns, 480-84creating a table, 467-70rows, 478-80

eval function

635

DB module, 570DB2 database servers, 455DBD modules, 454-56DBD::MySQL module, 459DBI (Database Interface), 433, 450-60

installing DBI, 452remote applications, 455

DBI module, 452connect method, 460-64disconnect method, 464-65do method, 472-74fetchall_arrayref method, 482fetchrow_arrayref method, 479, 480fetchrow_hashref method, 479-80

DBM (Database Manager), 433, 434-49AnyDBM_File module, 443-44formats, 444-45implementations, 434-35MLDBM (multi-level DBM), 446-49

dbmclose function, 542dbmopen function, 543debugger, Perl, 34, 301-2debugging, 300-302

CGI, 420-22

default values, parameters, 265default variable, $_, 67defensive programming, 302-4defined function, 123, 543delete function, 543DELETE statement, SQL, 484delimiters

quote like delimiters, 44regular expressions, 167-68

dereferencing, 222-24{ } (curly brackets), 222, 227-> operator, 228-30

DESTROY method, 341, 362Devel modules, 571diagnostics module, 289-90, 568diamond operator, < >, 181-82Search::Dict module, 575die function, 543directories, 212directory handles, 213DirHandle module, 571disconnect method, DBI module, 464-65disconnect_all method, DBI module, 464DNS (domain name service), 496do function, 310-11, 543do loops, 138do method, DBI module, 471, 472-74do_push method, CGI::Push module, 412

DocumentRoot command, Apache, 379domain name service (DNS), 496dotted quads, 495double-quoted strings, 41-43DROP TABLE statement, SQL, 484dump function, 543Data::Dumper module, 445, 446, 571Dumpvalue module, 571DynaLoader module, 571

E-e switch, 291-92, 582$^E variable, 535each function, 543elements, 75

arraysaccessing an element, 91-94accessing many elements, 94-96adding an element, 90-91references to elements, 224

literal listsaccessing an element, 80-82accessing many elements, 82-86

else keyword, 126-28elsif keyword, 126-28Empress database servers, 455encapsulation, 340endgrent function, 543endhostent function, 543endnetent function, 543endprotoent function, 543endpwent function, 544endservent function, 544English module, 571entries, databases, 437-38

deleting an entry, 484reading an entry, 438

entries, hashesadding an entry, 107-8removing an entry, 108

Env module, 571%ENV variable, 384-87, 535environment variables, HTTP, 386-87eof function, 544eq comparison operator, 58, 121Errno module, 571error messages, 280-83errors

See "bugs".

escape sequences, 32, 42-43regular expressions, 152-62

eval function, 544

exec function

636

exec function, 494, 544exists function, 117, 544exit function, 544exp function, 544Exporter module, 313-14, 571extension modules, 309ExtUtils modules, 571-72

F-F switch, 298-99, 582Fatal module, 572fcntl function, 544Fcntl module, 572FETCH method, 370, 372fetchall_arrayref method, DBI module, 482fetchrow_array method, DBI module, 466, 478fetchrow_arrayref method, DBI module, 479, 480fetchrow_hashref method, DBI module, 479-80FETCHSIZE method, 372fields module, 568fields, databases, 450file handles, 179-81

accessing a file handle, 195-96ARGV file handle, 183buffering, 199-200passing file handles as parameters, 264-65pipes, 201-7print function, 190-94select function, 197-99

File modules, 572-73file tests, 207-12, 539-40File::Find module, 314-15, 572File::Spec module, 318, 572File::Spec::Functions module, 318, 573FileCache module, 573FileHandle module, 573fileno function, 544files

copying a file, 190-92library files, 22log files, 197-99permissions, 200-201reading from a file, 179-82, 185-89entire file, 189multiple lines, 185-86opening the file, 179-81single lines, 181-82single paragraphs, 188-89single records, 186-88

sorting a file, 192-94, 195-96writing to a file, 189-200binary data, 196-97buffering, 199-200opening the file, 189-90

filetest module, 568filters, 183-85, 195-96File::Find module, 314-15, 572FindBin module, 573finish method, DBI module, 467flags, 139floating-point numbers

See "numbers".

flock function, 544flow charts, 113for loops, 129-32

arrays, 96-99iterator variables, 130-31

for statement modifier, 132-33foreach loops, 129-30fork function, 493-94, 545forking servers, 500-501format function, 545formline function, 545forms, HTML, 390-92

generating a form, 404-5, 407-9processing a form, 407-9

forward definition, subroutines, 248freeze method, Storable module, 445FreezeThaw module, 445Net::FTP module, 341-44functions, 29, 244, 539-65

arguments, 30-31array functions, 99file tests, 539-40

File::Spec::Functions module, 318, 573

Gg operator, 168gdbm databases, 434GDBM_File module, 573ge comparison operator, 58GET method, HTTP, 388-89, 391-92

parameters, 390-91

get methods, 338, 354-55get subroutine, 330getc function, 545getgrent function, 545getgrgid function, 545getgrnam function, 545gethostbyaddr function, 545gethostbyname function, 545gethostent function, 546getlogin function, 546getnetbyaddr function, 546

INSERT statement, SQL

637

getnetbyname function, 546getnetent function, 546Getopt::Long module, 317-18, 573Getopt::Std module, 316-17, 573getpeername function, 546getpgrp function, 546getppid function, 546getprint subroutine, 330getpriority function, 546getprotobyname function, 546getprotobynumber function, 546getprotoent function, 546getpwent function, 546getpwnam function, 546getpwuid function, 547getservbyname function, 547getservbyport function, 547getservent function, 547getsockname function, 547getsockopt function, 547getstore function, 330Glade, 504-5glob function, 547global variables, 65, 255-57globs, 212gmtime function, 547GNOME, 503-5goto statements, 144, 548graphical interfaces, 502-6

Glade, 504-5GNOME, 503-5GTK+, 503-5Qt, 505Tk, 503widgets, 502Win32 module, 506

grep function, 548grouping, regular expressions, 173-74gt comparison operator, 58, 121GTK+, 503-5

H-h switch, 582hashes, 75, 104-9

=> operator, 105conversion to arrays, 105-6creating a hash, 104-6entries, 107-8keys, 105names, 104passing hashes as parameters, 263-64

references to hashes, 220, 226-27references to subroutines, 268tied hashes, 435values, 105, 106-7accessing values, 108-9

hashing, 514HEAD method, HTTP, 388head subroutine, 330header method, CGI module, 398-400headers, HTML, 400-402headers, HTTP, 384-85

generating a header, 398-400

Hello World example, 24-28here-documents, 44-45hex function, 548hexadecimal system, 33-34, 39-41HTML, 382-84, 392-405

forms, 390-92generating a form, 404-5, 407-9processing a form, 407-9

headers, 400-402

HTTPheaders, 384-85generating a header, 398-400

methods, 388-89, 391-92parameters, 390-91

variables, 385-87

httpd.conf file, Apache, 379

I-i switch, 295, 582-I switch, 298, 582I18N::Collate module, 573if statement modifier, 124if statements, 117-19

else keyword, 126-28elsif keyword, 126-28

IIS (Internet Information Server), 380, 381import function, 548@INC array, 298, 312, 536%INC variable, 536indentation, 30index function, 549inetd program, 501-2infinite loops, 136-37Informix database servers, 455Ingres database servers, 455inheritance, 340-41, 364-68

constructors, 349methods, 365-66overriding a method, 366-68

inline commentsregular expressions, 172

INSERT statement, SQL, 470-72

installation, Perl

638

installation, Perl, 6-10Linux/Unix, 6-8Windows, 8-10

instancesSee "objects".

int function, 549INT signal, 491integer module, 568integers

See "numbers".

interactive scripts, CGI, 389-420Interbase database servers, 455Internet Information Server (IIS), 380, 381interpolation, strings, 41, 68-69

regular expressions, 151-52

interpreted code, 20-21Inter-Process Communication

See "IPC".

IO module, 573IO::Select module, 498-99, 574IO::Socket module, 495, 497-98, 574

clients, 498servers, 499-502

ioctl function, 549IP addresses, 495IPC (Inter-Process Communication), 487-94

backtick quoting, 490exec function, 494fork function, 493-94networking, 488, 494-502qx operator, 490signal handlers, 492-93signals, 490-93CHLD signal, 494

system function, 489-90wait function, 494

IPC modules, 574@ISA array, AnyDBM_File module, 444iterator variables, 96, 130-31

aliases, 131-32

Jjoin function, 170, 549

Kkeys function, 549keys, databases, 450keys, hashes, 105keys, Windows registry, 380keywords, 29kill function, 549

Kleene's notation, 148

L-l switch, 299, 582$^L variable, 534labels, 143languages, computers, 19-20last function, 140, 549lazy evaluation, 55lc function, 549lcfirst function, 549LDAP, 518-19le comparison operator, 58, 121length function, 550less module, 568lexical variables, 65-67, 258lib module, 568Bundle::libnet module, 331library files, 22link function, 550linked lists, 239-40Linux

MySQL installation, 457-59Perl installation, 6-8

list context, 89lists, 75-86

arrays, 86-104assignments, 87-91conversion to hashes, 105-6matrices, 231-32references to arrays, 220

elements, 75accessing an element, 80-82accessing many elements, 82-86

flattening a list, 79-80linked lists, 239-40literal lists, 75-86assignments, 83

mixed lists, 77-80passing lists as parameters, 261print function, 76-77qw operator, 79ranges, 84-86reverse function, 85slices, 82-83, 86

literal lists, 75-86assignments, 83

literals, 37local function, 260, 550locale module, 568localtime function, 550log files, 197-99, 520log function, 550

Net::Ping module

639

logic errors, 280logical operators

See "Boolean operators".

login method, 342-43Getopt::Long module, 317-18, 573lookaheads, regular expressions, 174-75lookbehinds, regular expressions, 175-76loop variables, 96loops, 128-29

bugs, 141-43do loops, 138for loops, 129-32iterator variables, 130-31

foreach loops, 129-30infinite loops, 136-37labels, 143last function, 140next function, 141until loops, 139while loops, 134-35

lstat function, 550lt comparison operator, 58lvalues, 64

arrays, 87-91literal lists, 83

Bundle::LWP module, 330-31

Mm operator, 168, 550-M switch, 295-96, 582machine code, 20manpages, Perl, 12map function, 550Math modules, 506-18, 574Math::BigFloat module, 506-10, 574Math::BigInt module, 506-10, 574Math::Complex module, 512-13, 574Math::Trig module, 510-12, 574matrices, 231-32metacharacters, 152-62

\b metacharacter, 157-58anchors, 153-54character classes, 155-57quantifiers, 159-61

methods, 338, 339, 351-55accessor methods, 351class vs object methods, 353-54constructors, 341, 348-51DESTROY method, 341, 362get/set methods, 338, 354-55HTTP, 388-89inheritance, 365-66overriding a method, 366-68

polymorphism, 339private methods, 358-60utility methods, 360-61

mirror function, 331mixed lists, 77-80mkdir function, 550MLDBM (multi-level DBM), 446-49modifiers, statements

See "statement modifiers".

modifiers, regular expressions, 151, 168-69inline modifiers, 172-73

modules, 21, 309-32, 567-77@INC array, 312bundles, 329-31core modules, 22do function, 310-11extension modules, 309installing a module, 323-26PPM, 323

package hierarchies, 312-13pragmatic modules, 309, 567-68require function, 311serializing modules, 445standard modules, 309, 314-22, 569-77submitting a module to CPAN, 331use function, 312

msgctl function, 550msgget function, 550msgrcv function, 550msgsnd function, 551Msql databases, 456multi-level DBM (MLDBM), 446-49multiple assignments, 64-65my function, 260, 551MySQL databases, 456-60DBD::MySQL module, 459

N-n switch, 292-94, 582named parameters, 266names, variables, 67

arrays, 86hashes, 104

namespaces, 256ndbm databases, 434NDBM_File module, 574ne comparison operator, 58, 121Net modules, 574-75Net::FTP module, 341-44Net::Ping module, 496-97

networking

640

networking, 488, 494-502clients, 496-97, 498domain name service (DNS), 496inetd program, 501-2IO::Select module, 498-99IO::Socket module, 497-98, 499-502IP addresses, 495Net::Ping module, 496-97ports, 495servers, 499-502forking servers, 500-501

sockets, 495blocking, 498

TCP (Transmission Control Protocol), 497, 498UDP (User Datagram Protocol), 497

new method, CGI module, 409next function, 141, 551no function, 551not Boolean operator, 54, 123numbers, 38-41

arithmetic operators, 46-48++, -- operators, 63-64

binary system, 33, 39-41, 49bitwise operators, 49-51Boolean operators, 53-55comparison operators, 51-53, 120complex numbers, 512-13conversion to strings, 45-46floating-point numbers, 39hexadecimal system, 33-34, 39-41integers, 38-39logical values, 119octal system, 33, 39-41

OO module, 575$^O variable, 535object-oriented programming, 335-75

classes, 339, 345-63encapsulation, 340inheritance, 340-41, 364-68

objects, 337attributes, 338, 347-48, 349-51class attributes, 355-58

creating an object, 341bless function, 345-47constructors, 341, 348-51

destroying an object, 341, 361-62methods, 338, 339, 351-55accessor methods, 351class vs object methods, 353-54get/set methods, 338, 354-55private methods, 358-60utility methods, 360-61

oct function, 551octal system, 33, 39-41

ODBC, 433, 455odbm databases, 434OO, OOP

See "object-oriented programming".

Opcode module, 575open function, 551

pipes, 201

open source software, 23opendir function, 551operating systems, 4operators, 46-60, 244

++, -- operators, 63-64=> operator, 105arithmetic operators, 46-48assignment operators, 61-62multiple assignments, 64-65

bitwise operators, 49-51Boolean operators, 53-55, 123-24comparison operatorsnumbers, 51-53, 120strings, 57-59, 121-22

concatenation operator, 55overloading operators, 507precedence, 47-48, 59-60repetition operator, 56-57See also "functions".

ops module, 568or Boolean operator, 54, 123Oracle database servers, 455ord function, 57-58, 551overload module, 568overloading operators, 507

P-p switch, 292-94, 582-P switch, 582pack function, 551-54package function, 554package hierarchies, 312-13package variables

See "global variables".

packages, 22param method, CGI module, 390-91parameters, subroutines, 249-50

@_ variable, 260-61arrays as parameters, 263-64default values, 265file handles as parameters, 264-65lists as parameters, 261named parameters, 266references as parameters, 262

parent processes, 493passwords, 513-15

Qt

641

patch pumpkin holder, 24patterns

See "regular expressions".

PDL (Perl Data Language), 510Perl

ActivePerl, 380advantages of Perl, 2-3, 22-23availability, 6databases, 433-85DBM, 434-49

debugger, 34, 301-2embedding Perl in C programs, 521functions, 244help, 10-13history, 1-2installation, 6-10Linux/Unix, 6-8Windows, 8-10

library files, 22manpages, 12-13modules, 21, 309-32, 567-77bundles, 329-31core modules, 22extension modules, 309pragmatic modules, 309, 567-68standard modules, 309, 314-22, 569-77

object-oriented programming, 335-75operating systems, 4operators, 244packages, 22programsstructure, 28-31, 113-145writing a program, 24-28

regular expression engine, 163-65releases, 23-24resources, 13-15source code, 21subroutines, 243-77Topaz project, 24uses of Perl, 3-4

Perl Data Language (PDL), 510Perl Package Manager (PPM), 323perldoc command, 11PerlScript, 23, 520permissions, files, 200-201Personal Web Server (PWS), 380-81Net::Ping module, 496-97pipe function, 554PIPE signal, 491pipes, 195, 201-7Pod modules, 575pointers, 218

See also "references".

polymorphism, 339pop function, 100, 554ports, 495

pos function, 554POSIX character classes, 158POSIX module, 575POST method, HTTP, 388, 389, 391-92

parameters, 390-91

PostgreSQL database servers, 455PPM (Perl Package Manager), 323pragmatic modules, 309, 567-68precedence, operators, 47-48, 59-60

++, -- operators, 63arithmetic operators, 47-48assignment operators, 62Boolean operators, 54

pre-declaring subroutines, 248prepare method, DBI module, 466CGI::Pretty module, 403-4, 570primary keys, databases, 469print function, 27, 554

file handles, 190-94lists, 76-77

printf function, 554private methods, 358-60procedural programming, 335processes, 490

See also "IPC".

programming languages, 19-20programs, CGI

See "scripts, CGI".

programs, Perlbig programs, 275-76comments, 28-29, 304structure, 28-31, 113-45blocks, 30statements, 29

writing a program, 24-28defensive programming, 302-4object-oriented programming, 335-75Unix, 26Windows, 25-26

prompts, 5prototype function, 554prototypes, subroutines, 254-55public key cryptography, 515-18pumpkin holding, 24push function, 100, 554CGI::Push module, 412-15, 570push_delay method, CGI::Push module, 412PWS (Personal Web Server), 380-81

Qq, qq operators, 44, 554Qt, 505

quantifiers, regular expressions

642

quantifiers, regular expressions, 159-61queries, SQL, 465-84quotemeta function, 554qw operator, 79, 555qx operator, 490, 555

Rrand function, 555ranges, 84-86re module, 568read function, 555readdir function, 555readline function, 555readline operator, < >, 181-82readlink function, 555readpipe function, 555records, databases, 450, 478-80records, files, 186recursion, subroutines, 268-75

terminating conditions, 268

recv function, 555redirection, CGI, 411-12redo function, 555ref function, 555reference counts, 230-31

anonymous references, 231

references, 217-41anonymous references, 218, 220-21arrays, 220elements, 224

creating a reference, 218-20data structures, 231-40autovivification, 232-36linked lists, 239-40matrices, 231-32trees, 236-39

dereferencing, 222-24{ } (braces), 222, 227-> operator, 228-30

hashes, 220, 226-27modifying data, 225-26passing references as parameters, 262subroutines, 266-67, 268callbacks, 267

symbolic references, 287

registry, Windows, 380-81regular expression engine, 163-65regular expressions, 147-77

backreferences, 162-63, 176bugs, 171-72character classes, 155-57POSIX, 158Unicode, 158

delimiters, 167-68escape sequences, 152-62grouping, 173-74

inline comments, 172interpolation, 151-52join function, 170Kleene's notation, 148lookaheads, 174-75lookbehinds, 175-76metacharacters, 152-62anchors, 153-54character classes, 155-57

modifiers, 151, 168-69inline modifiers, 172-73

repetition, 159-61split function, 169-70transliteration, 171word boundaries, 157-58

relational databases, 450releases, Perl, 23-24remote databases, 461-62rename function, 556repetition operator, 56-57require function, 311, 556reset function, 556resources, Perl, 13-15return statements, 252, 556return values, 250-53, 303

caching, 252-53

reverse function, 85, 556arrays, 99

rewinddir function, 556rindex function, 556rmdir function, 556rows, tables, databases, 478-80runaway strings, 282-83runtime scope, 258-60

S\s metacharacter, 156\S metacharacter, 156s operator, 168, 556-s switch, 296-98, 583-S switch, 583Safe module, 575salts, 514save method, CGI module, 409scalar context, 89scalar function, 556scalars, 38

variables, 60-61

scope, variables, 65-67, 255-60global variables, 255-57lexical variables, 258namespaces, 256runtime scope, 258-60

stat function

643

ScriptAlias command, Apache, 379scripts, CGI, 381-422

debugging, 420-22execution environment, 392interactive scripts, 389-420security, 422-30

sdbm databases, 434SDBM_File module, 575Search::Dict module, 575SearchServer database servers, 456security, 513-18

CGI, 422-30external programs, 423-26tainted variables, 426-27wrappers, 429

passwords, 513-15

seek function, 556seekdir function, 557select function, 557

file handles, 197-99

IO::Select module, 498-99, 574SELECT statement, SQL, 475-78SelectSaver module, 576self_url method, CGI module, 405-6SelfLoader module, 576semctl function, 557semget function, 557semop function, 557send function, 557separators, 186serializing, 446serializing modules, 445server push, CGI, 412-15servers, 499-502

configuration, 377-81Apache, 378-79IIS, 380, 381PWS, 380-81

database servers, 454-56forking servers, 500-501inetd program, 501-2

Apache::Session module, 418-20sessions, CGI, 418-20set methods, 338, 354-55setpgrp function, 557setpriority function, 557setsockopt function, 557shebang line, 290Shell module, 576shift function, 102-3, 557shmctl function, 557shmget function, 558shmread function, 558

shmwrite function, 558shutdown function, 558%SIG variable, 535signal handlers, 492-93signals, IPC, 490-93

CHLD signal, 494

sigtrap module, 568sin function, 558single-quoted strings, 41-43sleep function, 558slices, lists, 82-83, 86

arrays, 94-96

socket function, 558Socket module, 495, 576IO::Socket module, 495, 497-98, 574

clients, 498servers, 499-502

socketpair function, 558sockets, 495

blocking, 498clients, 498IO::Socket module, 497-98servers, 499-502

sort function, 103-4, 558Win32::Sound module, 320-21source code, 20-21File::Spec module, 318, 572File::Spec::Functions module, 318, 573splice function, 559split function, 169-70, 559sprintf function, 559SQL (Structured Query Language), 450, 465-84

CREATE TABLE statement, 468-69DELETE statement, 484DROP TABLE statement, 484INSERT statement, 470-72SELECT statement, 475-78UPDATE statement, 474-75

sqrt function, 559srand function, 559stacks, 100standard input, 70-71, 179standard modules, 309, 314-22, 569-77

Benchmark module, 318-20, 569CPAN module, 326-29, 570File::Find module, 314-15, 572File::Spec module, 318, 572Getopt::Long module, 317-18, 573Getopt::Std module, 316-17, 573Win32 modules, 320-22

standard output, 70start_html method, CGI module, 400-402stat function, 559

statement modifiers

644

statement modifiers, 124-25for modifier, 132-33if modifier, 124unless modifier, 124-25while modifier, 138-39

statements, 29blocks, 30if statements, 117-19return statements, 252unless statements, 124

Getopt::Std module, 316-17, 573STDERR construct, 179STDIN construct, 70-71, 179

while loops, 135-36

STDOUT construct, 179Storable module, 445-46, 445STORE method, 370-72STORESIZE method, 372strict module, 286-89, 568strings, 27, 41-44

++, -- operators, 64comparison operators, 57-59, 121-22concatenation operator, 55conversion to numbers, 45-46, 57double-quoted strings, 41-43escape sequences, 32, 42-43here-documents, 44-45interpolation, 41, 68-69regular expressions, 151-52

logical values, 119q, qq operators, 44, 554repetition operator, 56-57runaway strings, 282-83single-quoted strings, 41-43

structure, Perl programs, 28-31, 113-145blocks, 30comments, 28-29loops, 128-29statements, 29

structuresSee "data structures".

study function, 561sub keyword, 245, 561subclasses, 340subroutines, 243-77

callbacks, 267context, 253-54defining a subroutine, 245-47sub keyword, 245

functions compared to subroutines, 244importing a subroutine, 313operators compared to subroutines, 244order of declaration, 247-49forward definition, 248

parameters, 249-50@_ variable, 260-61

arrays as parameters, 263-64default values, 265file handles as parameters, 264-65lists as parameters, 261named parameters, 266references as parameters, 262

prototypes, 254-55recursion, 268-75terminating conditions, 268

references to subroutines, 266-67, 268return statements, 252return values, 250-53caching, 252-53

scope, variables, 255-60global variables, 255-57lexical variables, 258runtime scope, 258-60

signal handlers, 492-93

subs module, 568substr function, 561superclasses, 340switches, 290-300, 579-83

-0 switch, 299, 579-a switch, 298-99, 579-c switch, 294, 579-e switch, 291-92, 582-F switch, 298-99, 582-i switch, 295, 582-I switch, 298-l switch, 299, 582-M switch, 295-96, 582-n switch, 292-94, 582-p switch, 292-94, 582-s switch, 296-98, 583-T switch, 299-300, 583

Sybase database servers, 456Symbol module, 576symbolic references, 287symlink function, 561syntax errors, 280, 281-83Sys modules, 576syscall function, 561sysopen function, 561sysread function, 562sysseek function, 562system function, 489-90, 562syswrite function, 562

T-T switch, 299-300, 583$^T variable, 535tables, databases, 450, 467-75

columns, 480-84creating a table, 467-70rows, 478-80

\W metacharacter

645

tainted variables, 426-27TCP (Transmission Control Protocol), 497, 498tell function, 562telldir function, 562Term modules, 576terminating conditions, recursion, 268Test module, 576Text modules, 576thaw method, Storable module, 445tie function, 435-37, 562Tie modules, 576-77TIEARRAY method, 369, 372tied function, 436, 563tied hashes, 435TIEHANDLE method, 369TIEHASH method, 369Win32::TieRegistry module, 321-22TIESCALAR method, 369, 372time function, 563Time modules, 577times function, 563Tk, 503Topaz project, 24tr operator, 171, 563transliteration, regular expressions, 171Transmission Control Protocol (TCP), 497, 498trees, 236-39

traversing a tree, 238-39

Math::Trig module, 510-12, 574truncate function, 563

U-u switch, 583-U switch, 583uc function, 563ucfirst function, 563UDP (User Datagram Protocol), 497umask function, 563undef function, 189, 437, 564Unicode, 31-32

character classes, 158

Unify database servers, 456UNIVERSAL module, 577Unix, 26

CGI server configuration, 377-79Perl installation, 6-8

unless statement modifier, 124-25unless statements, 124unlink function, 564unpack function, 564

unshift function, 102-3, 564untie function, 437, 564until loops, 139UPDATE statement, SQL, 474-75url method, CGI module, 405-6URLs (universal resource locators), 388-89, 405-6use diagnostics command, 289-90use function, 312, 564use strict command, 286-89use warnings command, 284-86

scope, 285-86

User Datagram Protocol (UDP), 497User modules, 577utf8 module, 568utility methods, 360-61utime function, 564

V-v switch, 583-V switch, 583values function, 564values, hashes, 105, 106-7

accessing values, 108-9

variables, 37, 60$_ (default) variable, 67aliases, 131-32arrays, 86-104assignments, 61-62multiple assignments, 64-65

global variables, 65hashes, 104-9HTTP, 385-87environment variables, 386-87

interpolation, strings, 41, 68-69iterator variables, 130-31lexical variables, 65-67names, 67scalar variables, 60-61scope, 65-67, 255-60global variables, 255-57lexical variables, 258namespaces, 256runtime scope, 258-60

tainted variables, 426-27tying a variable to a class, 369-74

vars module, 568vec function, 564virtual machine code, 21

W\w metacharacter, 156\W metacharacter, 156

w switch

646

-w switch, 27-28, 583-W switch, 583$^W variable, 535wait function, 494, 565waitpid function, 565Wall, Larry, 1-2wantarray function, 253, 565warn function, 565warnings, 27warnings module, 284-86, 568while loops, 134-35

STDIN construct, 135-36

while statement modifier, 138-39white space, 32widgets, 502Win32 modules, 320-22, 506Win32::Sound module, 320-21Win32::TieRegistry module, 321-22Windows, 25-26

CGI server configuration, 379-81MySQL installation, 457

Perl installation, 8-10registry, 380-81

Windows 2000bugs, 34Perl installation, 8

World Wide Web, 22-23, 520wrappers, CGI, 429write function, 565

Xx operator, 168-x switch, 583-X switch, 583$^X variable, 535XML, 519xor Boolean operator, 54

Yy operator, 565

y operator

647

This work is licensed under the Creative Commons Attribution-NoDerivs-NonCommercial License. To view a copy of thislicense, visit http://creativecommons.org/licenses/by-nd-nc/1.0 or send a letter to Creative Commons, 559 Nathan Abbott Way,Stanford, California 94305, USA.

The key terms of this license are:

Attribution: The licensor permits others to copy, distribute, display, and perform the work. In return, licensees must give theoriginal author credit.

No Derivative Works: The licensor permits others to copy, distribute, display and perform only unaltered copies of the work --not derivative works based on it.

Noncommercial: The licensor permits others to copy, distribute, display, and perform the work. In return, licensees may notuse the work for commercial purposes -- unless they get the licensor's permission.