quigley.book page 939 friday, october 12, 2007 1:01...
TRANSCRIPT
939
Index
SYMBOLS→ (infix operator), 86, 404! (not operator), 150" (double quotes), 73–74"*" variable, 344# sign, 35$#arrayname variable, 81$AUTOLOAD function, 462–464$ (dollar sign), 47$p reference, 350$& scalar variable, 215$_scalar variable, 80, 203$_special scalar variable, 184$! variable, 286$$ variable, 727$= variable, 771$@ variable, 757$x scalar, 403%ENV hash, 129–130%INC hash, 131% (modulus operator), 153%SIG hash, 130–131& (ampersand), 326' ' (single quotes), 47, 74( ) (parentheses), 263* (asterisk), 251, 402** (exponentiation operator), 153* (multiplication operator), 153+ (addition operator), 153
- (subtraction operator), 153.. (range operator), 82, 161. (dot metacharacter), 235, 238/ (division operator), 153:: syntax, 449–451:standard functions, 561; (semicolon), 414, 866< (less than operator), 144<= (less than or equal to operator), 144= (assignment operator), 71, 141–143= (equal sign), 474= operator, 877> (greater than operator), 144>= (greater than or equal to operator), 144> operator, 879?!pattern, 273?<!pattern, 273?<=pattern, 273? placeholder, 659? (question mark), 256@_array, 330, 415@EXPORT array, 380, 388@INC array, 371–374@ISA array, 388
methods, calling, 460–462@ sign, 47, 70@* variable, 778[] (square brackets), 240
anonymous arrays, 406
quigley.book Page 939 Friday, October 12, 2007 1:01 PM
940 Index
\ (backslash), 47, 235, 348hard references, 403–404system call issues, 687
\n (newline) character, 239^ (caret), 235{} (curly braces), 78–79
anonymous hashes, 407|| (or operator), 150| (pipe symbol), 303, 307~&& (and operator), 149~ (tilde), 779
Aabs function, 815abs2rel function, 688accept function, 798, 815accessing. See also opening
DBM files, 506–508directories, 698–701elements, 82–84, 89files, modifying, 709–710log files, 517–519symbol tables, 365system files, 291
access methods, 431ACTION attribute, 552ActivePerl, 11, 391ActiveState
mod_perl, installing, 929system calls, 686
addingcolumns, 637entries, 666–667extensions, 395multiple classes, 471primary keys, 638tables, 626–627whitespace, 216
addition operator (+), 153addresses
bless function, 429–431hard references, 401. See also hard
referencesnetworking, 787–794sockets, 796
URLs, 519–521$x scalar, 403
-A $file, 320AF_INET family, 795–796AF_UNIX family, 795–796aggregate functions, 902. See also SQL
functionsalarm function, 762–763, 815aliases, 401, 898–899
creating, 344private, 345–347references, passing, 345selective aliasing, 348–349
ALTER command, 899altering. See also modifying
metacharacters, 263tables, 899–900
alternative characters, 237alternative quotes, 17, 75–77ALTER TABLE command, 637American National Standards Institute
(ANSI), 610ampersand (&), 326anchors, metacharacters, 236, 258–261and operator (&&), 149AND operator (SQL), 880–881anonymous arrays, 406–407, 408anonymous hashes, 92, 407, 410, 428anonymous subroutines,
414–415, 453–455anonymous variables, 428
references, 406–407ANSI (American National Standards
Institute), 610AnyDBM_FILE, 505Apache. See also servers
access logs, 518client/server databases, 604mod_perl
installing, 928–938overview of, 925–926
appending files, opening for, 293–294Applications folder (MySQL), 615architecture, client/server databases, 604ARCHIVE attribute, 690
quigley.book Page 940 Friday, October 12, 2007 1:01 PM
Index 941
argumentscommand-line, passing at, 27named, 564passing, 310–319pointers as, 352–353positional, 565subroutines, 330–344
ARGV array, 310–311arithmetic functions, 164–168arithmetic operators, 153–154arrays, 15
@_, 415@EXPORT, 388@INC, 371–374@ISA, 388, 460–462anonymous, 406–407, 408ARGV, 310–311@_array, 330assignment, 80–82associative, 87, 493–494context and subroutines, 342elements, accessing, 82–84functions, 100–117. See also hash
functionschomp, 100chop, 100delete, 101exists, 101grep, 102join, 102–103map, 103–105pack, 105–107pop, 107push, 108reverse, 116–117shift, 108–109sort, 114–116splice, 109–110split, 110–114unpack, 105–107unshift, 117
hashes, 410–412input, assigning to, 98–99multidimensional, 86–87, 408–410slices, 84–86
tying, 497–500variables, 80–87, 92–93wantarray function, 343–344
ascending order, 121assertions, 258–261
look around, 273–276assignment
arrays, 80–82, 98–99hash variables, 88–89input to scalar variables, 94scalar variables, 77–78
assignment operator (=), 71, 141–143assignment statements, 71–72associating files, 32associative arrays, 87
functions, 116. See also hash functionstie function, 493–494
associativity operators, 139–168asterisk (*), 251, 402atan2 function, 815attributes, 423, 434
ACTION, 552files, 689–692PrintError, 655RaiseError, 655
autodecrement operators, 154–155autoincrement operators, 154–155AUTOLOAD function, 354–356, 460AUTOLOAD subroutine, 462–464$AUTOLOAD variable, 354automating
error handling, 655installation of Perl modules, 391
awk programming language, 383
Bbackquotes, 748–749backslash (\), 47, 235, 348
hard references, 403–404system call issues, 687
“Bare word” error, 45base classes, 465base modules, tying scalars, 495bases (DNA), 916BEGIN subroutines, 357
quigley.book Page 941 Friday, October 12, 2007 1:01 PM
942 Index
behaviorof objects, 429of variables, defining, 494
BETWEEN statement, 883-B $file, 320-b $file, 320BIGINT data type, 624binary files (Win32), 292–293bind function, 797, 816binding. See also tying
columns, 657–659dynamic, 445–451parameters, 662–664
bind_param() method, 662–664binmode function, 292, 816bioinformatics, 915bioperl, 919–923bitwise logical operators, 156–159black box, 325bless function, 429–431, 816BLOB data type, 624blocks, 171–177
continue, 194–196labeled without loops, 189–191local function, 332–334
Boolean data types, 143bracketed character class, 246BREAK key, 760browsers, 513, 522. See also interfaces
Query Browser (MySQL), 616–617, 865bsd-db (Berkeley DB) implementation, 505bug reports, mod_perl, 927–928built-in functions, 36, 325. See also functionsBunce, T., 505buttons, radio, 537–541bytes, returning current positions, 299
Ccaches, queries, 664–665call-by-reference, 330–332, 344–358
typeglobs, 344–349call-by-value, 332–338caller function, 816calling
methods, 460–462processes, 721
subroutines, 326–330, 338system calls. See system callsunnamed methods, 355
can() method, 462canonpath function, 688capturing metacharacters, 266–273caret (^), 235carpout function, 593–594Carp.pm module, 755case sensitivity, 45
databases, 612i modifiers, 215, 222SQL, 867–868
case_tolerant function, 688catching
errors, 758–759signals, 760–761
catdir function, 688categories, Perl, 10catfile function, 688catpath function, 688c (complement) option, 279–280-C $file, 320-c $file, 320CGI (Common Gateway Interface), 599–601
CGI.pm module, 559–598clients and servers, 516–521e-mail, 555–559encoded query strings, 544–548environment variables, 531–535forms, 535–559, 548–551GET method, 541–544HTML, overview of, 526–531MySQL entries, 672–677POST method, 551–555scripts, 527–530
communication, 531–535here documents, 63–66
static and dynamic Web pages, 513–515Web pages, creating with HTML,
522–526CGI.pm module, 559–598
advantages of, 560error handling, 593–596forms, 572–577
elements, 577–579
quigley.book Page 942 Friday, October 12, 2007 1:01 PM
Index 943
generating input fields, 579–593HTML form methods, 564–571HTTP header methods, 596–598overview of, 559–560print function, 562–564programming styles, 560–562
charactersasterisk (*), 402c (complement) option, 279–280classes, 240–245
bracketed, 246POSIX, 245–247
d (delete) option, 278–279funny, 70, 131, 134–136hex-encoded, 546–547metacharacters. See metacharactersnewline (\n), 239s (squeeze) option, 276, 280storage, viewing, 297tr function, 276–280Unicode, 281–282
CHAR(x) data type, 624chdir function, 697check boxes, 537–541checkbox() method, 583CHECKBOX type, 536Checking.pm module, 683child processes, 721Chinese, 281chmod function, 702–704, 816chomp function, 95–96, 100, 816chop function, 95–96, 100, 817chown function, 704, 817chr function, 817Christianson, Tom, 424, 453chroot function, 817C language, adding extensions, 395classes, 423, 425
characters, 240–245bracketed, 246POSIX, 245–247Unicode, 281
creating, 28derived, 465–471Exporter.pm module, 380–381hierarchies of, 460
House, 428–429instantiating, 28methods, 431–433, 436–438
DBI, 645–647overview of, 425–427UNIVERSAL, 460variables, tying to, 493–504
clausesFROM, 629GROUP BY, 903JOIN, 634ORDER BY, 884WHERE, 630–633WHERE, 876
clearing fields, 593CLEAR method, 500clients, 516–521, 785
databases, 604–610MySQL, 615programs, 800–806requests, waiting for, 798
closedir function, 699, 817close function, 817closing
databases, 506filehandles, 286pipes, 286
closuresand objects, 455–459overview, 453–455
clustering metacharacters, 263–266columns
adding, 637binding, 657–659databases, 608–609dropping, 637selecting, 629–630, 872–873
command-linearguments, passing, 27, 310–319forms, testing, 576–577man pages, 10–11MySQL, 614switches, 2, 39–43, 856–857
-c, 42–43-e, 40-n, 40–42
quigley.book Page 943 Friday, October 12, 2007 1:01 PM
944 Index
commandsALTER TABLE, 637CREATE DATABASE, 622–623debugger, 860–861find, 692“GRANT”, 619MySQL, 611, 621–638od, 297peridoc, 10, 382pod, 476–477SELECT, 629SQL, 680–681, 865–868
ALTER, 899DESCRIBE, 870–871EXTRACT, 909INSERT, 885–886LIMIT, 874–875SELECT, 871–885SHOW, 870–871show databases, 868–869UPDATE, 886–887USE, 869
start, 744–745substitutions, 748–749
comments, 14, 35regular expressions, 216
commit() method, 671–672common gateway interface. See CGIcommunication between CGI scripts and
servers, 531–535comparing operands, 143–145compiling use function, 378–379complex data structures, 91–93components of relational databases, 605–610composite character classes, 282compound statements, 171–177Comprehensive Perl Archive Network.
See CPANCOMPRESSED attribute, 690conditional constructs, 172–177conditional modifiers, if, 204–205conditional operators, 19, 20, 159–161conditions, 201
LIKE, 881NOT LIKE, 881
connect function, 798–799, 817connecting
databases, 648–649MySQL, 614–616sockets, 798–799TCP/IP, 516
connection-oriented socketson remote machines, 806–808on same machines, 800–806
connect() method, 648consoles, mysql, 864constants, 16
print function, 49–55constructors, 425, 434–436
parameters, passing, 438–440constructs, 14–25
conditional, 172–177if, 172–173if/else, 173–174if/elseif/else, 174–175quotes, 75–77unless, 175–177
CONTENT_LENGTH environment variable, 552
contexthashes, 131–132subroutines, 342–344
continue blocks, 194–196control
loops, 188–196structures, 171–177
conventions, namingSQL, 867variables, 70–71
converting strings to numbers, 138cookies, headers, 529copying values, 332–338Copy.pm module, 686cos function, 817CPAN, 5
DBI, 644–645modules from, 390–397MySQL, 678overview of, 9
Cpan.pm module, 391–393
quigley.book Page 944 Friday, October 12, 2007 1:01 PM
Index 945
CREATE DATABASE command, 622–623CREATE TABLE statement, 623croak function, 386cross joins, 896crypt function, 817-c switch, 42–43, 530curdir function, 688curly braces ({}), 78–79
anonymous hashes, 407current byte positions, returning, 299
Ddatabase driver module (DBD), 639databases
case sensitivity, 612closing, 506columns, 608–609connecting, 648–649creating, 620–621, 622–623, 888–889DBM. See DBMdisconnecting, 648–649dropping, 620–621, 638, 901fields, 607–608indexes, 609keywords, 611MySQL, 603. See also MySQLnaming conventions, 611northwind, 680opening, 506primary keys, 609records, 607–608reserved words, 611–612result-sets, 612–613rows, 608, 609schemas, 609searching, 619–621selecting, 623servers, 606SQL. See SQLtables, 607tie function, 494–494
Data Definition Language. See DDLdata encapsulation, 425, 428DATA filehandles, 205–208datagram sockets, 795
Data Manipulation Language. See DMLdata types, 14
Boolean, 143mixing, 138–139MySQL, 623–626SQL, 889–890
DATE: YYYY-MM-DD data type, 624Date and Time functions, 906–910dates, formatting, 907DATETIME data type, 624DBD (database driver module), 639DBI (Database Independent Interface), 638–648
MySQL entries, 672–677dbmclose function, 506, 818DBM (Database Management)
files, 505–512accessing, 506–508deleting entries from, 510–512retrieving data from, 508–510
modules, 493dbmopen function, 506, 818d (delete) option, 278–279DDL (Data Definition Language), 888–901
databases, creating, 888–889keys, creating, 893–895relations, 896–899tables
altering, 899–900dropping, 901
tables, creating, 891–893debuggers, 858–862debugging, 38–39DECIMAL data type, 624declarations, 326
prototypes, 338decoding query strings, 545default messages, modifying, 594–596defaults() method, 593defined function, 79, 818defining
methods, 431predefined methods, 494report templates, 767–770subroutines, 326–330
delete function, 101, 126–127, 510, 818
quigley.book Page 945 Friday, October 12, 2007 1:01 PM
946 Index
DELETE key, 760DELETE method, 500DELETE statement, 887–888deleting
directories, 696entries, 667–668entries from DBM files, 510–512rows, 635–636
delimiters, modifying substitutions, 219de-referencing. See also references
pointers, 350–352, 404–406derived classes, 465–471Descartes, A., 505descendants, 721DESCRIBE command, 870–871DESTROY method, 451, 494destructors, 425, 451–452devnull function, 688-d $file, 319diagnostics, 29
MySQL errors, 656–657diagnostics pragma, 57–58die function, 287–288, 755–757, 818digits, metacharacters, 236directories
accessing, 698–701creating, 695–696deleting, 696files. See fileshtdocs, 537h2xs tool, 395–397@INC array, 371modifying, 697Perl, 6searching, 692–695system calls and files, 687–689systems and file attributes, 689–692UNIX, 698
DIRECTORY attribute, 690disconnecting databases, 648–649disconnect() method, 650distribution, CPAN, 5division operator (/), 153DML (Data Manipulation Language), 871–888
SELECT command, 871–885DNA, overview of, 915–917
documentationAnyDBM_FILE, 505HTML, 11man pages, 10–11mod_perl, 927–928MySQL, 614, 681–682peridoc command, 10, 382public user interfaces, 474–479scalars, tying, 495Win32::GetLastError, 756
documentshere documents, 63–66, 563, 752–753,
759–760HTML. See HTML; Web pages
do function, 818do keyword, 326dollar sign ($), 47domains
Internet, 795sockets, 795–796UNIX, 795
dot metacharacter (.), 235, 238DOUBLE data type, 624double quotes ("), 73–74do/until loops, 181do/while loops, 181downloading mod_perl, 927–928drop-down menus, 591dropping
columns, 637databases, 620–621, 638tables, 638, 901
dump function, 819dynamic binding, 445–451dynamic report writing, 781–783dynamic Web pages, 513–515
Eeach function, 119–120, 819editing
files, 317–319keys in MySQL, 615
-e $file, 319elements
accessing, 82–84, 89forms, CGI.pm module, 577–579
quigley.book Page 946 Friday, October 12, 2007 1:01 PM
Index 947
TITLE, 522e-mail, CGI and, 555–559e modifiers, 223encapsulation, 425, 428encoded QUERY_STRING environment
variable, 544–548end-of-file (EOF) marker, 285END subroutines, 357entering the debugger, 859–860entries
adding, 666–667deleting, 667–668MySQL, 672–677system calls. See system callsupdating, 668–670
ENUM data type, 624environments, processes, 723–725environment variables, 373. See also variables
CGI, 531–535CONTENT_LENGTH, 552QUERY_STRING, 544–548
EOF (end-of-file) marker, 285eof function, 315–317, 819equality operators, 146–149equal sign (=), 474errno variable, 685errors. See also debugging
“Bare word”, 45catching, 758–759CGI.pm module, 593–596handling, 755Internal Server Error message, 562logs, 526, 530–531MySQL, 655–665scripts, 38–39standard, HTML, 526subroutines, 326system, 287
escape sequences, 49-e switch, 40Ethernet layer, 786
addresses, 787eval function, 757–760, 819evaluating
expressions, 137, 223, 757–760operators, 18. See also precedence
exec function, 741–742, 819executing
scripts, 36statements
SQL, 864–865subroutines, 327
exercises, SQL, 912–914exists function, 101, 127–128, 819EXISTS method, 500exit function, 743–744, 819exiting the debugger, 859–860exp function, 819exponentiation operator (**), 153Exporter.pm module, 380–381exporting modules, 379–385expressions
evaluating, 137, 223, 757–760regular, 26. See also regular expressions
extensions, creating, 395EXTRACT command, 909
FfatalsToBrowser function, 593–594fcntl function, 820fetching
modules, 391results, 650–654values, 657
FETCH method, 494fetchrow_hashref() method, 653-f $file, 319fields
clearing, 593databases, 607–608input, generating, 579–593reports
filling, 779–781multiline, 778–779
symbolsdesignator, 768display, 768
text, 537–541width of, 60
filehandles, 323–324ARGV, 310closing, 286
quigley.book Page 947 Friday, October 12, 2007 1:01 PM
948 Index
filehandles (Continued)DATA, 205–208directories, accessing, 698–701naming, 285null, ARGV and, 311–315printing, 45processes, 725–728reading from, 288references, 347–348, 417–418reports, modifying, 770–771select function, 294–295user-defined, 285–309
filename expansion, 753–755file_name_is_absolute function, 688fileno function, 820file protocol, 519, 521files, 24
associating, 32attributes, 689–692DBM, 505–512
accessing, 506–508deleting entries from, 510–512retrieving data from, 508–510
directories, system calls, 687–689editing, 317–319filehandles. See filehandleshashes, loading from, 128–129initialization, setting PERL5LIB variables,
373–374locking, 295–296logs
accessing, 517–519errors, 530–531
low-level I/O, 712–715modifying, 709–710opening, 285
for appending, 293–294for reading, 286–290for writing, 291–292
output of filters, sending to, 306–307.pl, 374–378, 388.pm, 378–379, 384, 426pod, 474–476reading from, 40renaming, 708–709
Script File, 14searching, 692–695seek function, 296–299source
creating, 522viewing, 513
statistics, 710–712storage, 297system, 285, 291tell function, 296–299testing, 319–321
eof function, 315–317UNIX, 689–692Win32 binary, 292–293Windows, 689–692
File::Spec module, 687–689FILE type, 536filling
fields, 779–781out forms, 543
filters, 302. See also pipesinput, 307–309output, 303–306
find command, 692Finder (MySQL), 615Find::File module, 692–693find() method, 692FIRSTKEY method, 500flags, modifiers, 60FLOAT data type, 624flock function, 295–296, 820foreach loops, 184–188foreach modifiers, 210foreign keys, creating, 895fork function, 739–741, 820for loops, 182–184format function, 820format keyword, 773format specifiers, 59–60formatting
databases, 888–889date and time, 907keys, 893–895tables, 891–893top-of-the-page, 771–776
quigley.book Page 948 Friday, October 12, 2007 1:01 PM
Index 949
formline function, 820forms
CGI and, 535–559CGI.pm module, 572–577
elements, 577–579generating input fields, 579–593
command-line, testing, 576–577filling out, 543GET method, 541–544HTML methods, 564–571input, 536–537processing, 548–551viewing, 538
forward reference, 328free form language, 14FROM clause, 629FTP (File Transfer Protocol), 519full joins, 896function-oriented style, CGI scripts, 561–562functions, 23, 325–330, 815–844
abs, 815accept, 798, 815alarm, 762–763, 815arithmetic, 164–168arrays, 100–117
chop, 100delete, 101exists, 101grep, 102join, 102–103map, 103–105pack, 105–107pop, 107push, 108reverse, 116–117shift, 108–109sort, 114–116splice, 109–110split, 110–114unpack, 105–107unshift, 117
atan2, 815AUTOLOAD, 354–356, 460$AUTOLOAD, 462–464bind, 797, 816
binmode, 292, 816bless, 429–431, 816built-in, 36caller, 816carpout, 593–594chdir, 697chmod, 702–704, 816chomp, 95–96, 100, 816chop, 95–96, 100, 817chown, 704, 817chr, 817chroot, 817close, 817closedir, 817connect, 798–799, 817cos, 817croak, 386crypt, 817dbmclose, 506, 818dbmopen, 506, 818defined, 79, 818delete, 510, 818die, 287–288, 755–757, 818do, 818documentation, searching, 11dump, 819each, 819eof, 315–317, 819eval, 757–760, 819exec, 741–742, 819exists, 819exit, 743–744, 819exp, 819fatalsToBrowser, 593–594fcntl, 820fileno, 820File::Spec module, 687–689flock, 295–296, 820fork, 739–741, 820format, 820formline, 820geipwuid, 823getc, 97–98, 820getgrent, 821getgrgid, 821
quigley.book Page 949 Friday, October 12, 2007 1:01 PM
950 Index
functions (Continued)getgrnam, 821getgrp, 822gethostbyaddr, 793–794, 821gethostbyname, 793–794, 821gethostent, 792–793, 821getlogin, 726, 821getnetbyaddr, 821getnetbyname, 822getnetent, 822getpeername, 822getppid, 727, 822getpriority, 728–729, 822getprotobyname, 789, 822getprotobynumber, 789–790, 823getprotoent, 788–789, 823getpwent, 732–733, 823getpwnam, 733–734, 823getpwuid, 734getservant, 790–791getservbyname, 791, 823getservbyport, 791–792, 824getservent, 824getsockname, 824glob, 754–755, 824gmtime, 735–737, 824goto, 824grep, 825hash, 118–128
delete, 126–127each, 119–120exists, 127–128keys, 118values, 119
hex, 825host information, 792–794import, 825index, 825int, 825ioctl, 825join, 825keys, 825kill, 761–762, 825last, 826lc, 826
lcfirst, 826length, 826link, 706–707, 826listen, 797, 826local, 332–334, 345–347, 826localtime, 36, 737–738, 826lock, 826log, 827lstat, 710–712, 827m, 827map, 827mkdir, 827msgctl, 827msgget, 828msgrev, 828msgsnd, 828my, 828MySQL
strings, 905new, 828next, 828no, 828not, 828oct, 829open, 285, 829opendir, 698, 829ord, 829our, 829pack, 830package, 830perldoc, 686pgrp, 727pipe, 830pop, 830pos, 831print, 36, 46–58, 342, 831
CGI.pm module, 562–564diagnostics pragma, 57–58literals, 49–55quotes, 47–48strict pragma, 58-w switch, 55–57
print(), 325printf, 59–66, 831
flag modifiers, 60
quigley.book Page 950 Friday, October 12, 2007 1:01 PM
Index 951
format specifiers, 59–60here documents, 63–66sprintf function, 62
protocols, 788–790prototype, 831push, 831q, 831qq, 831quotemeta, 831qw, 831qx, 831rand, 166, 832rand(), 325read, 96–97, 552, 712–713, 832readdir, 698–699, 832readline, 832readlink, 707–708, 832readpipe, 832recv, 832redo, 832ref, 418–420, 833rename, 708–709, 833require, 374, 833reset, 833return, 326, 340, 833reverse, 833rewinddir, 833rindex, 833rmdir, 696, 833s, 834scalar, 834seek, 296–299, 713–714, 834seekdir, 700–701, 834select, 294–295, 834
report templates, 776–778semctl, 834semget, 834semop, 835send, 835servers, 790–792set_message, 594setpgrp, 835setpriority, 729, 835setsockopt, 835shift, 835
shmctl, 835shmget, 835shmread, 836shmwrite, 836sin, 836sleep, 763, 836socket, 836socketpair, 836sort, 837special string, 162–164splice, 837split, 837sprintf, 837SQL, 901–910
Date and Time, 906–910numeric, 902–904strings, 905
sqrt, 837srand, 166, 837:standard, 561stat, 710–712, 838study, 838sub, 838subs, 358substr, 839symlink, 707–708, 839syscall, 686, 747–748, 839sysopen, 839sysread, 713, 839sysseek, 839system, 750–752, 840syswrite, 713, 840tell, 296–299, 714–715, 840telldir, 700, 840tie, 493–494, 841tied, 841time, 735, 842times, 735, 842tr, 276–280, 842truncate, 842uc, 842ucfirst, 842umask, 842undef, 80, 510, 842unlink, 706–707, 843
quigley.book Page 951 Friday, October 12, 2007 1:01 PM
952 Index
functions (Continued)unmask, 704–705unpack, 843unshift, 843untie, 506, 843use, 378–379, 843utime, 709–710, 843values, 843vec, 844wait, 742–743, 844waitpid, 742–743, 844wantarray, 343–344, 844warn, 757, 844write, 771, 844y, 276–280
funny characters, 70, 131, 134–136asterisk (*), 402
Ggarbage collection, 451–452gdbm (GNU DBM) implementation, 505geipwuid function, 823generating
input, 579–593random numbers, 165
ge operator, 145GetAttributes() function, 690getc function, 97–98, 820getgrent function, 821getgrgid function, 821getgrnam function, 821getgrp function, 822gethostbyaddr function, 793–794, 821gethostbyname function, 793–794, 821gethostent function, 792–793, 821getlogin function, 726, 821GET method, 541–544getnetbyaddr function, 821getnetbyname function, 822getnetent function, 822getpeername function, 822getppid function, 727, 822getpriority function, 728–729, 822getprotobyname function, 789, 822getprotobynumber function, 789–790, 823
getprotoent function, 788–789, 823getpwent function, 732–733, 823getpwnam function, 733–734, 823getpwuid function, 734getservant function, 790–791getservbyname function, 791, 823getservbyport function, 791–792, 824getservent function, 824getsockname function, 824getters, 425, 433-g $file, 320gid, 723global change, 217global substitutions, 220global variables, preventing use of, 336–338globbing, 753–755glob function, 754–755, 824g modifiers, 214, 220gmtime function, 735–737, 824Goldberg, Ian, 165goto function, 824“GRANT” command, 619graphical user interfaces. See GUIsgreater than operator (>), 144greater than or equal to operator (>=), 144greediness of metacharacters, 250–258grep function, 102, 825GROUP BY clause, 903grouping metacharacters, 263–266gt operator, 145GUIs (graphical user interfaces), 394. See also
interfacesMySQL tools, 616–619PPM, 643––644
Hhandles, statements, 650–654handling errors, 755. See also errorshard links, 705–708hard references, 349–354
pointers, 403–406symbolic references, comparing to, 401–403
hashes, 15, 87–91%, 70anonymous, 407, 410, 428
quigley.book Page 952 Friday, October 12, 2007 1:01 PM
Index 953
arrays, 92–93, 410–412context, 131–132%ENV, 129–130files, loading from, 128–129hashes of hashes, 91–92, 412–414%INC, 131input, assigning to, 99%SIG, 130–131sorting, 120–126special, 129–131tying, 500–504
hash functions, 118–128delete, 126–127each, 119–120exists, 127–128keys, 118values, 119
headers, HTTP, 529–530, 596–598help, mod_perl, 928here documents, 63–66, 563, 752–753
eval function and, 759–760hex-encoded characters, 546–547hex function, 825HIDDEN attribute, 690HIDDEN type, 536hierarchies of classes, 460hl() method, 565host information functions, 792–794hostnames, 520House class, 428–429h2ph script, 747–748htdocs directory, 537HTML (Hypertext Markup Language)
documentation, 11forms, methods, 564–571links to CGI scripts, 534–535overview, 526–531pod documentation, translating, 479
HTTP (Hypertext Transfer Protocol)headers, 529–530, 596–598servers, 516–517status codes, 517–519
h2xs tool, 395–397hyperlinks, 534. See also linksHypertext Markup Language. See HTML
Iicons, PPM windows, 394IDEs (Integrated Development
Environments), 34if constructs, 172–173if/else constructs, 173–174if/elseif/else constructs, 174–175if modifiers, 204–205if statements, 172IMAGE type, 537i modifiers, 215, 222implementation of DBM, 505import function, 825importing
modules, 379–385use function, 378–379
indexes, databases, 609index function, 825infix operator (→), 86, 404inheritance, 424, 425, 460–473
multiple, 465, 471single, 465
initialization files, 373–374inner joins, 896input
arrays, assigning to, 98–99fields, generating, 579–593filters, 307–309forms, 536–537hashes, assigning to, 99pipes, 526POST method, 551–555
input to scalar variables, assigning, 94INSERT command, 885–886installing
DBI, 639–645mod_perl, 928–938modules, 391MySQL, 613–614
instancesmethods, 431–433, 436–438
passing parameters to, 440–442variables, 465
instantiating classes, 28INT data type, 624
quigley.book Page 953 Friday, October 12, 2007 1:01 PM
954 Index
Integrated Development Environments. See IDEs
interfacesCGI, 63–66. See also CGIDBI, 638–648error handling, 755–760operating systems, 747–755PPM, 393–397public user, 474–479signals, 760–764system calls, 685–721
Internal Server Error message, 562Internet
clients and servers, 516–521domains, 795
Internet Explorer, 522Internet Protocol (IP), 786
addresses, 787interpreted language, overview of, 2interpreters, 2
pod files, 474, 477searching, 32
int function, 825invoking
methods, 432subroutines, 326
ioctl function, 825isa() method, 462ISS client/server databases, 604-i switch, 317–319
JJapanese, 281join function, 102–103, 688, 825joining tables, 634–635joins, 896
Kkernels
system calls. See system callsUNIX, 689
Enter key, 247Tab key, 247keys, 87
Tab, 247Enter, 247creating, 893–895hashes, sorting, 121–124MySQL, editing, 615primary
adding, 638databases, 609tables, adding, 626–627
signals, 760keys function, 118, 825keywords
databases, 611do, 326format, 773private, 429protected, 429public, 429require, 326sub, 327, 357, 414use, 326
-k $file, 320kill function, 761–762, 825
Llabels, 45, 589–590
loop control, 188–189nested loops and, 191–194
languagesawk, 383C, adding extensions, 395DDL. See DDLDML. See DMLPerl. See PerlSQL, 604. See also SQLUnicode characters, 281
last function, 826last statements, 192layers, Ethernet, 786lcfirst function, 826lc function, 826left joins, 896length function, 826le operator, 145
quigley.book Page 954 Friday, October 12, 2007 1:01 PM
Index 955
less than operator (<), 144less than or equal to operator (<=), 144lexical variables, 453-l $file, 320libraries, 29, 370–390
modules, 385–388OOP, 479–484Perl 5 module, 383–385pod files, 474–476
LIKE condition, 881LIMIT command, 874–875linebreaks, 34–35link function, 706–707, 826links, 513
CGI scripts, 534–535hard and soft, 705–708
Linux. See UNIXActivePerl, 391database servers, 606PPM, 644
listen function, 797, 826lists
chop and chomp functions, 100CPAN, 390. See also CPANof lists, 408–410mailing, mod_perl, 928multidimensional arrays, 86–87null parameter, 328of values, hash of hashes, 414
literals, 16print function, 49–55printing, 51–55
loading hashes from files, 128–129local function, 332–334, 345–347, 826localtime function, 36, 737–738, 826Location headers, 529Locator Box, searching, 520lock function, 826locking files, 295–296log function, 827logical operators, 149–151logical word operators, 151–152logs
errors, 526
filesaccessing, 517–519errors, 530–531
LONGBLOB data type, 624LONGTEXT data type, 624look around assertions, 273–276loops, 20–22
for, 182–184control, 188–196DATA filehandles, 205–208do/until, 181do/while, 181foreach, 184–188modifiers, 209–210nested and labels, 191–194repetition with, 177–199until, 179–182while, 177–179
low-level file I/O, 712–715lstat function, 710–712, 827lt operator, 145
MMac OS
ActivePerl, 391files, reading, 286–290scripts, startup, 32
mailing lists, mod_perl, 928mailto protocol, 519main package, 70, 424managing
DBM. See DBMPPM, 391, 393–397RDBMS. See RDBMS
man pages, 10–11manual error handling, 655–656map function, 103–105, 105–107, 827markers, EOF, 285matching
global matches, 214metacharacters, 236–238modifiers, 210patterns, 881–882. See pattern matching
MEDIUMBLOB data type, 624
quigley.book Page 955 Friday, October 12, 2007 1:01 PM
956 Index
MEDIUM INT data type, 624MEDIUMTEXT data type, 624menus
drop-down, 591pop-up, 537–541, 591–592
messages, 594–596. See also e-mailmetacharacters, 26, 235–280
alternation, 263anchors, 258–261capturing, 266–273greediness of, 250–258grouping, 263–266look around assertions, 273–276pattern matches, repeating, 250–276single characters, 236, 238–247tr function, 276–280whitespace, 247–249y function, 276–280
metasymbols, 240methods, 379, 423, 425, 431–433
bind_param(), 662–664calling, 460–462can(), 462CGI.pm module, 577–579checkbox(), 583classes, 436–438, 645–647CLEAR, 500commit(), 671–672connect(), 648defaults(), 593DELETE, 500DESTROY, 451, 494disconnect(), 650EXISTS, 500FETCH, 494fetchrow_hashref(), 653find(), 692FIRSTKEY, 500GET, 541–544hl(), 565HTML forms, 564–571HTTP headers, 596–598instances, 436–438, 440–442invoking, 432
isa(), 462new, 495NEXTKEY, 500param, 572parent, overriding, 471–473POP, 497popup_menu(), 586–589, 591–592POST, 544, 551–555predefined, 494PUSH, 497radio_group(), 586–589reset(), 592rollback(), 671–672start_form, 572start_html, 572STORE, 494submit, 572submit(), 592textfield(), 580–582types of, 431–432UNIVERSAL, 462–464unnamed, calling, 355VERSION(), 462
-M $file, 320m function, 827MIME (multipurpose Internet extension)
types, 529miscellaneous characters, 237mixing data types, 138–139mkdir function, 827m modifiers, 261modifiers
e, 223flags, 60foreach, 210g, 214, 220i, 215, 222if, 204–205loops, 209–210m, 261matching, 210regular expressions, 204–210s, 239substitution, 216–226
quigley.book Page 956 Friday, October 12, 2007 1:01 PM
Index 957
tr, 277unless, 207until, 209while, 209x, 216
modifying@_array, 330default messages, 594–596directories, 697filehandles, reports, 770–771files, 709–710substitution delimiters, 219tables, 637, 899–900
mod_perlinstalling, 928–938overview of, 925–926web sites, 927–928
modules, 29, 363–370, 850–855. See also packages
base, tying scalars, 495Carp.pm, 755CGI.pm, 559–598Checking.pm, 683Copy.pm, 686from CPAN, 390–397Cpan.pm, 391–393creating, 388–390DBM, 493Exporter.pm, 380–381exporting and importing, 379–385File::Spec, 687–689Find::File, 692–693object-oriented, 481–484OOP, 423–425, 433–44Perl, 9Perl 5, standard Perl library, 383–385.pm files, 378–379pragmas. See pragmasShell.pm, 749–750Socket.pm, 808–812SomeModule.pm, 381standard Perl library, 385–388Switch.pm, 199use function, 378–379
Win32:Process, 746–747Win32:Spawn, 745–746
modulus operator (%), 153monitoring public/private borders, 427m operator, 210–216msgctl function, 827msgget function, 828msgrev function, 828msgsnd function, 828multidimensional arrays, 86–87
lists of lists, 408–410multiline fields, reports, 778–779multiple files, passing, 317multiple inheritance, 465, 471multiple placeholders, 660–661multiplication operator (*), 153multipurpose Internet extension types. See
MIME typesmy function, 828my operator, 334–336, 345–347MySQL
clients, 615client/server databases, 604–610commands, 611, 621–638communication, 610–613connecting, 614–616CPAN, 678data types, 623–626DBI, 638–648documentation, 681–682entries, 672–677errors, 655–665GUI tools, 616–619installing, 613–614keys, editing, 615overview of, 603, 613passwords, setting, 615–616phpMyAdmin tool, 618privilege system, 618–619Query Browser, 616–617, 865quotes, 654–655relational databases, 604–613searching, 619–621statements, 650–654, 666–670
quigley.book Page 957 Friday, October 12, 2007 1:01 PM
958 Index
MySQL (Continued)string functions, 905transactions, 670–672
mysql console, 864mysqld process, 606mysql service, 606
Nnamed arguments, 564named parameters, 442–444namespaces, 70, 423
packages. See packagessymbols, exporting and importing, 379
namingaliases, 898–899
creating, 344conventions
databases, 611SQL, 867
filehandles, 285files, 708–709hostnames, 520scripts, 34subroutines, 374variables, 70–71, 401
ndbm (new DBM) implementation, 505nested data structures, 408–414nested loops and labels, 191–194Netscape browsers, 522networking, 785
addresses, 787–794client/server models, 785client/server programs, 800–806protocols, 785–787Socket.pm module, 808–812sockets, 794–800
new function, 828newline (\n) character, 239new method, 495news protocol, 519next function, 828NEXTKEY method, 500next statements, 192niceness, 728–729no function, 828
non-blocking locks, 295NORMAL attribute, 690northwind databases, 607, 680not function, 828NOT LIKE condition, 881not operator (!), 150no_upwards function, 688-n switch, 40–42NTFS, 701nucleotides, 916NULL, 877null filehandles, ARGV and, 311–315null parameter lists, 328numbers, 16
keys, sorting hashes by, 121–122metacharacters, 236port, 787–788random, generating, 165strings, converting, 138
numeric expression, 137numeric functions, 902–904numeric literals, 49
printing, 52–53numeric values, relational operators and, 144
Oobject-oriented programming. See OOPobject-oriented style, CGI scripts, 560–562objects, 28, 423, 425, 486–491
closures and, 455–459DESTROY method, 451overview of, 428–429state of, 434
obtaining Perl, 6–8oct function, 829odbm (old DBM) implementation, 505od command, 297OFFLINE attribute, 690-o $file, 319OOP (object-oriented programming), 423–425
inheritance, 460–473modules, 433–44public user interfaces, 474–479standard Perl library, 479–484
opendir function, 698, 829
quigley.book Page 958 Friday, October 12, 2007 1:01 PM
Index 959
open function, 285, 829opening
databases, 506files, 285
for appending, 293–294for reading, 286–290for writing, 291–292
pipes, 302–309operands, 137
comparing, 143–145operating systems. See also Linux; UNIX;
Windowsinterfaces, 747–755
operationsdatabase, 493file locking, 295–296reading, 301–302writing, 301–302
operators, 18=, 877AND, 880–881and (&&), 149//, 877addition (+), 153arithmetic, 153–154assignment (=), 71, 141–143autodecrement, 154–155autoincrement, 154–155bitwise logical, 156–159conditional, 20, 159–161data types, mixing, 138–139division (/), 153equality, 146–149exponentiation (**), 153file test, 319–320ge, 145greater than (>), 144greater than or equal to (>=), 144gt, 145infix (→), 86, 404le, 145less than (<), 144less than or equal to (<=), 144logical, 149–151logical word, 151–152
lt, 145modulus (%), 153multiplication (*), 153my, 334–336, 345–347not (!), 150OR, 880–881or (||), 150overloading, 138overview of, 137precedence and associativity, 139–168range (..), 82, 161regular expressions, 210–232
m, 210–216pattern binding, 226–232s, 216–226
relational, 143–145special string, 162–164SQL, 631, 876subtraction (-), 153
Oppel, Andrew J., 603ORDER BY clause, 884ord function, 829OR operator, 880–881or operator (||), 150Orwant, J., 453our function, 829output
CGI scripts, 529for check boxes, 585filters, 303–306printing, 14for radio buttons, 588
overloading operators, 138overriding parent methods, 471–473ownership, 701–705
Ppackage function, 830packages, 363–370, 399–400
classes. See classesexporting and importing, 379–385main, 70, 424OOP, 423–425.pl files, 374–378PPM, 391
quigley.book Page 959 Friday, October 12, 2007 1:01 PM
960 Index
packages (Continued)pwd, 374standard Perl library, 370–390symbol tables, 365–370Tie::Scalar, 495variables, 69–70
packets, 786pack function, 105–107, 830packing data, 715–721parameters
binding, 662–664constructors, passing, 438–440instance methods, passing to, 440–442named, 442–444null lists, 328
param method, 572parent classes, 465parentheses (), 263parent methods, overriding, 471–473parent process ID, 727passing
arguments, 27, 310–319, 330–344filehandles by reference, 347–348, 417–418multiple files, 317parameters
to constructor methods, 438–440to instance methods, 440–442
pointers to subroutines, 353–354by reference with aliases, 345subroutines by reference, 415–417values to subroutines, 349–354
passwordsMySQL, setting, 615–616processes, 730–734UNIX, 732–733Windows, 730–732
PASSWORD type, 537PATHEXT variable, 33path function, 688pattern matching, 203, 234, 881–882. See
also regular expressionsbinding operators, 226–232repeating, 250–276saving, 215subpatterns, creating, 263
peridoc command, 10, 382Perl
directories, 6documentation. See man pagesinterpreted language, overview of, 2obtaining, 6–8overview of, 1–2versions, 3–5
perldoc function, 686PERL5LIB variables, setting, 373–374Perl 5 module, standard Perl library, 383–385Perl Package Manager. See PPMpermissions, 293
file locking, 295–296MySQL, 619system calls, 701–705
-p $file, 320pgrp function, 727phpMyAdmin tool (MySQL), 618pid, 721pipe function, 830pipes, 25
closing, 286input, 526opening, 302–309| (pipe symbol), 303, 307reading from, 41
placeholders, 659multiple, 660–661records, inserting, 661–662
.pl files, 374–378, 388
.pm files, 384, 426modules and, 378–379
pod (plain old documentation)commands, 476–477files, 474–476interpreters, 477translators, 477–479
pointers, 27, 349–354, 421as arguments, 352–353de-referencing, 350–352, 404–406hard references, 403–406nested data structures, 408–414overview of, 401passing to subroutines, 353–354
quigley.book Page 960 Friday, October 12, 2007 1:01 PM
Index 961
polymorphism, 424, 425, 445–451pop function, 107, 830POP method, 497popup_menu() method, 586–589, 591–592pop-up menus, 537–541port numbers, 787–788pos function, 831positional arguments, 565POSIX character classes, 245–247post-increment operators, 155POST method, 544, 551–555PPM (Perl Package Manager), 391, 393–397
DBI, installing, 639–645mod_perl, installing, 929
Practical Extraction and Report Language. See Perl
pragmas, 424, 848–850diagnostics, 57–58strict, 58
global variables, preventing use of, 336–338
symbolic references, 403Unicode, 281use function, 378–379warnings, 55–57
precedence, operators, 139–168predefined methods, 494predefined variables, 16pre-increment operators, 155preventing use of global variables, 336–338primary keys
adding, 638creating, 893–894databases, 609tables, adding, 626–627
PrintError attribute, 655printf function, 59–66, 831
flag modifiers, 60format specifiers, 59–60here documents, 63–66sprintf function, 62
print function, 36, 46–58, 342, 831CGI.pm module, 562–564diagnostics pragma, 57–58literals, 49–55
quotes, 47–48strict pragma, 58-w switch, 55–57
print() function, 325printing
filehandles, 45literals, 51–55output, 14strings, 67without quotes, 63–66words, 45
priorities, processes, 728–729privacy, classes and, 426–427private aliases, 345–347private keyword, 429privilege system (MySQL), 618–619processes, 721
calling, 721child, 721filehandles, 725–728mysqld, 606niceness, 728–729passwords, 730–734priorities, 728–729signals, sending, 761–762time and, 734–739UNIX, 721–723
creating, 739–744environments, 723–725
Windows, 723creating, 744–747environments, 723–725
process group ID, 727processing forms, 548–551programming
CGI.pm module, 560–562OOP. See OOP
programsCGI, 65, 514. See also CGI; scriptsclient/server, 800–806sendmail, 555user/driver, 442
properties, 434Unicode, 281
protected keyword, 429
quigley.book Page 961 Friday, October 12, 2007 1:01 PM
962 Index
protocolsfunctions, 788–790HTTP, 516–517IP, 786networking, 785–787SMTP, 555–559TCP, 786TCP/IP, 516–517, 785–787UDP, 786–787Web, 519
prototype function, 831prototypes, subroutines, 338–340public keyword, 429public methods, 423public/private borders, monitoring, 427public user interfaces, 474–479push function, 108, 831PUSH method, 497pwd package, 374
Qq construct, 75q function, 831qq construct, 75qq function, 831queries. See also databases
caches, 664–665client/server databases, 604SQL, 865–868
Query Browser (MySQL), 616–617, 865QUERY_STRING environment variable,
531, 544–548question mark (?), 256queues, creating sockets, 797Quick Start/Quick Reference, 13–29QUIT key, 760quotemeta function, 831quotes, 17
MySQL, 654–655print function, 47–48printing without, 63–66SQL, 877variables, 72–77
qw construct, 75qw function, 831
qx construct, 75qx function, 831
Rradio buttons, 537–541radio_group() method, 586–589RADIO type, 537RaiseError attribute, 655rand function, 166, 325, 832random numbers, generating, 165range operator (..), 82, 161RDBMS (relational database management
systems), 604components, 605–610
readdir function, 698–699, 832read function, 96–97, 552, 712–713, 832reading
from filehandles, 288from files, 40, 286–290operations, 301–302from pipes, 41from STDIN, 94–99
readline function, 832readlink function, 707–708, 832READONLY attribute, 690readpipe function, 832records
databases, 607–608placeholders, inserting, 661–662
recv function, 832redirecting STDOUT, 306redo function, 832redo statements, 192references, 13–29, 27
aliases, passing, 345anonymous variables, 406–407call-by-reference, 330–332, 344–358filehandles, 347–348, 417–418forward, 328hard, 349–354
comparing to symbolic references, 401–403
pointers, 403–406nested data structures, 408–414objects, 428. See also objects
quigley.book Page 962 Friday, October 12, 2007 1:01 PM
Index 963
overview of, 401$p, 350subroutines, 414–417symbolic, 344–349
ref function, 418–420, 833regular expressions, 26, 234
comments, 216metacharacters, 235–280
alternation, 263anchors, 258–261capturing, 266–273greediness of, 250–258grouping, 263–266look around assertions, 273–276pattern matches, repeating, 250–276single characters, 236, 238–247tr function, 276–280whitespace, 247–249y function, 276–280
modifiers, 204–210. See also modifiersoperators, 210–232
m, 210–216pattern binding, 226–232s, 216–226
overview of, 203statements, 204–210Unicode, 281–282
rel2abs function, 688relational database management systems
(RDBMS), 604components, 605–610
relational databases, 604–613components of, 605–610
relational operators, 143–145relations, DDL, 896–899remembering metacharacters, 266–273rename function, 708–709, 833renaming files, 708–709repeating
characters, 237pattern matching, 250–276
repetition with loops, 177–199reports, mod_perl bugs, 927–928report templates, 767–783
defining, 767–770
dynamic report writing, 781–783filehandles, modifying, 770–771filling fields, 779–781multiline fields, 778–779select function, 776–778top-of-the-page formatting, 771–776
requests, waiting for clients, 798require function, 374, 833require keyword, 326reserved words, 45
databases, 611–612SQL, 867
reset function, 833reset() method, 592RESET type, 537results, sorting, 884result-sets
databases, 612–613SQL, 868
retrievingdata from DBM files, 508–510rows, 608
return function, 326, 340, 833returning
current byte positions, 299filehandles, 294values
ref function, 418–420subroutines, 340–342
reverse function, 116–117, 833reverse order, sorting hash keys, 121–122revisions, 317–319rewinddir function, 833-r $file, 319Rieken, B., 787rindex function, 833rmdir function, 696, 833rollback() method, 671–672rootdir function, 688root users, 618Rosenberg, Barry, 72routines, @INC array, 371rows
databases, 608, 609deleting, 635–636
quigley.book Page 963 Friday, October 12, 2007 1:01 PM
964 Index
rules for quotes, 72–77runtime
binding, 445errors, 39require function, loading at, 374
Ssaving pattern matching, 215scalar function, 834scalars, 15
$, 70$&, 215$_, 203$ARGV, 310@_array, 330–332arrays, 81–82context and subroutines, 342hard references. See hard referenceshash variables, 87input, assigning input to, 94patterns, saving, 215tying, 494–496variables, 77–80$x, 403
schemas, databases, 609Schwartz, R. L., 427, 797scope
packages, 364of subroutines, 326variables, 69–70, 329
Script File, 14scripts
CGI, 527–530communication, 531–535here documents, 63–66
errors, 38–39executing, 36h2ph, 747–748naming, 34overview of, 37–38setup, 31–32startup, 32–33subroutines, 326. See also subroutinesUNIX, 2
sdbm (standard DBM) implementation, 505
searchingCPAN, 9, 390directories, 692–695files, 692–695greediness, turning off, 253, 256–258interpreters, 32Locator Box, 520MySQL, 619–621pattern matching, 203. See also regular
expressionstext editors, 34
seekdir function, 700–701, 834seek function, 296–299, 713–714, 834SELECT command, 629SELECT command (SQL), 871–885SELECT DISTINCT statement, 873–874select function, 294–295, 834
report templates, 776–778selecting
columns, 629–630, 872–873databases, 623entries, MySQL, 672–677
selective aliasing, 348–349SELECT type, 537semctl function, 834semget function, 834semicolons (;), 414semicolons (;), 866semop function, 835send function, 835sending signals to processes, 761–762sendmail program, 555sequences
DNA, 916escape, 49examples of, 917918
servers, 516–521, 785CGI scripts, communication between,
531–535databases, 604–610, 606functions, 790–792HTTP, 516–517programs, 800–806SMTP, 555–559
services, mysql, 606
quigley.book Page 964 Friday, October 12, 2007 1:01 PM
Index 965
SetAttributes() function, 690set_message function, 594setpgrp function, 835setpriority function, 729, 835setsockopt function, 835setters, 425, 433setting
MySQL passwords, 615–616PERL5LIB variables, 373–374
-S $file, 320-s $file, 319s function, 834shbang line, 32Shell.pm module, 749–750shift function, 108–109, 835shmctl function, 835shmget function, 835shmread function, 836shmwrite function, 836short-circuit operators, 149–151SHOW commands, 870–871show databases command, 868–869shutdown, sockets, 799–800SIGALARM signal, 762signals, 760–764
catching, 760–761processes, sending, 761–762SIGALARM, 762
Simple Mail Transfer Protocol. See SMTPsin function, 836single characters, metacharacters, 236, 238–247single inheritance, 465single quotes (' '), 47, 74Slaymaker, Barrie, 453sleep function, 763, 836slices
arrays, 84–86hash variables, 90–91
SMALLINT data type, 624s modifiers, 239SMTP (Simple Mail Transfer Protocol),
555–559socket function, 836socketpair function, 836Socket.pm module, 808–812
socketsaddresses, 796client requests, waiting for, 798connecting, 798–799creating, 796domains, 795–796networking, 794–800queues, creating, 797shutdown, 799–800types of, 795
soft links, 705–708Solaris, ActivePerl, 391SomeModule.pm module, 381s operator, 216–226sort function, 114–116, 837sorting
arrays, 114–116hashes, 120–126results, 884tables, 633–634
source filescreating, 522viewing, 513
special hashes, 129–131special literals, 51
printing, 54–55special scalars for saving patterns, 215special string operators, 162–164special variables, 845–848splice function, 109–110, 837split function, 110–114, 837splitpath function, 688sprintf function, 62, 837SQL INSERT statement, 627SQL (Structured Query Language), 604
case sensitivity, 867–868commands, 680–681, 865–868
ALTER, 899DESCRIBE, 870–871EXTRACT, 909INSERT, 885–886LIMIT, 874–875SELECT, 871–885SHOW, 870–871show databases, 868–869
quigley.book Page 965 Friday, October 12, 2007 1:01 PM
966 Index
SQL (Continued)commands (Continued)
UPDATE, 886–887USE, 869
databases, 868–871data types, 889–890DDL. See DDLDML. See DMLexercises, 912–914functions, 901–910
Date and Time, 906–910numeric, 902–904strings, 905
MySQL. See MySQLnaming conventions, 867operators, 631, 876overview of, 863queries, 865–868quotes, 877reserved words, 867result-sets, 868standardizing, 864statements
BETWEEN, 883DELETE, 887–888executing, 864–865SELECT DISTINCT, 873–874terminating, 611, 866
tables, 869–871sqrt function, 837square brackets ([]), 240
anonymous arrays, 406srand function, 166, 837Srinivasan, S., 433s (squeeze) option, 276, 280standard errors, HTML, 526standardizing SQL, 864standard Perl library, 370–390
@INC array, 371–374modules, 385–388OOP, 479–484Perl 5 module, 383–385pod files, 474–476
start command, 744–745start_form method, 572start_html method, 572
startupPERL5LIB variable, setting, 373–374scripts, 32–33
statements, 34–35, 35–36, 424assignment, 71–72compound, 171–177CREATE TABLE, 623handles, 650–654if, 172last, 192MySQL, 666–670next, 192redo, 192regular expressions, 204–210SQL
BETWEEN, 883DELETE, 887–888executing, 864–865SELECT DISTINCT, 873–874terminating, 611, 866
SQL INSERT, 627subroutines, 327. See also subroutinesswitch, 196–199unless, 172“useDBI”, 647
state of objects, 434stat function, 710–712, 838static methods, 431, 436–438static Web pages, 513–515statistics, files, 710–712status codes, HTTP, 517–519STDERR, 287
error logs, 530–531STDIN, 94–99STDOUT, 306Stein, L., 560Stevens, W. R., 788STOP key, 760storage files, 297STORE method, 494stream sockets, 795strict pragma, 58
global variables, preventing use of, 336–338symbolic references, 403
strings, 17literals, 49–51, 53–54
quigley.book Page 966 Friday, October 12, 2007 1:01 PM
Index 967
MySQL functions, 905numbers, converting, 138printing, 67special string operators, 162–164
Structured Query Language. See SQLstudy function, 838sub function, 838sub keyword, 327, 357, 414submit method, 572submit() method, 592SUBMIT type, 537subpatterns, creating, 263subroutines, 23, 325–330, 360–361. See also
functionsanonymous, 414–415, 453–455arguments, passing, 330–344AUTOLOAD, 462–464AUTOLOAD function, 354–356BEGIN and END, 357call-by-reference, 344–358calling, 326–330context, 342–344defining, 326–330hard references, 349–354importing, 379–385naming, 374pointers, passing to, 353–354prototypes, 338–340references, 414–417return values, 340–342user-defined, 343–344
subs function, 358substitutions
216-226commands, 748–749delimiters, modifying, 219global, 220newline (//n) character, 239
substr function, 839subtraction operator (-), 153superusers, 618suppression indicator, 779switches
-c, 530command-line, 2, 39–43, 856–857
-c, 42–43
-e, 40-n, 40–42
-i, 317–319-w, 567
print function, 55–57Switch.pm module, 199switch statements, 196–199symbolic references, 344–349
hard references, comparing to, 401–403strict pragma, 403
symbolsencoding, 545fields
designator, 768display, 768
importing, 379–385metasymbols, 240tables, 365–370, 427
symlink function, 707–708, 839syntax, 14–25
::, 449–451errors, 39testing with -c switch, 530
syscall function, 686, 747–748, 839sysopen function, 839sysread function, 713, 839sysseek function, 839SYSTEM attribute, 690system calls, 685–721
directories, 687–689accessing, 698–701creating, 695–696deleting, 696modifying, 697searching, 692–695
fileslow-level I/O, 712–715modifying, 709–710renaming, 708–709statistics, 710–712
hard and soft links, 705–708packing and unpacking data, 715–721permissions, 701–705
system directories and file attributes, 689–692
system errors, 287. See also errors
quigley.book Page 967 Friday, October 12, 2007 1:01 PM
968 Index
system files, 285accessing, 291
system function, 750–752, 840syswrite function, 713, 840
Ttables
adding with primary keys, 626–627altering, 899–900CREATE TABLE statement, 623creating, 891–893data, inserting, 627–629databases, 607dropping, 638, 901joining, 634–635modifying, 637MySQL privilege system, 618–619sorting, 633–634SQL, 869–871symbols, 365–370, 427updating, 636–637
tags, HTMLcreating, 522forms, 535
TCP/IP, 516, 785–787telldir function, 700, 840tell function, 296–299, 714–715, 840telnet protocol, 519templates, 338. See also prototypes
pack and unpack functions, 106reports, 767–783
defining, 767–770dynamic report writing, 781–783filehandles, modifying, 770–771filling fields, 779–781multiline fields, 778–779select function, 776–778top-of-the-page formatting, 771–776
TEMPORARY attribute, 690Terminal application (MySQL), 615terminating SQL statements, 611, 866testing
eof function, 315–317files, 319–321forms at the command-line, 576–577
syntax with -c switch, 530text
fields, 537–541files, opening, 285
TEXTAREA type, 537TEXT data type, 624text editors, 2
HTML, creating Web pages in, 522–526searching, 34
textfield() method, 580–582TEXT type, 537-T $file, 320-t $file, 320tied function, 841tie function, 493–494, 841Tie::Scalar package, 495tilde (), 779time
formatting, 907and processes, 734–739
TIME: hh-mm-ss data type, 624time function, 735, 842times function, 735, 842TIMESTAMP data type, 624TINYBLOB data type, 624TINYINT data type, 624TINYTEXT data type, 624TITLE element, 522tmpdir function, 688tools
GUIs, MySQL, 616–619h2xs, 395–397phpMyAdmin (MySQL), 618privilege system (MySQL), 618–619
top-of-the-page formatting, 771–776tracking cookies, 529transactions, MySQL, 670–672translators
pod, 477–479pod files, 474
Transmission Control Protocol (TCP), 786tr function, 276–280, 842truncate function, 842turning off
capturing, 272–273
quigley.book Page 968 Friday, October 12, 2007 1:01 PM
Index 969
case sensitivity, 215, 222greediness, 251, 256–258
tyingarrays, 497–500hashes, 500–504scalars, 494–496variables to classes, 493–504
typeglobs, 344–349, 401symbol tables, 365
typesdata, 14. See also data typesof errors, 38–39of input for forms, 536–537of joins, 896of literals, 49–55of methods, 431–432MIME, 529o of inheritance, 465of operators, 141–168pack and unpack functions, 106of sockets, 795of text editors, 34of variables, 69
Uucfirst function, 842uc function, 842-u $file, 320uid, 723umask function, 842undef function, 80, 510, 842Unicode, 281–282Unicode Consortium, 281Uniform Resource Locators. See URLsUNIVERSAL class, 460UNIVERSAL method, 462–464UNIX
commands. See commandsdatabase servers, 606directories, 695, 698domains, 795files, 286–290, 689–692hard and soft links, 705–706kernels, 689passwords, 732–733
permissions, 701processes, 721–723
creating, 739–744environments, 723–725
scripts, 2scripts, startup, 32sendmail program, 555sockets, 795–796
unless constructs, 175–177unless modifiers, 207unless statements, 172unlink function, 706–707, 843unmask function, 704–705unnamed methods, calling, 355unpack function, 105–107, 843unpacking data, 715–721unshift function, 117, 843untie function, 506, 843until loops, 179–182until modifiers, 209UPDATE command, 886–887updating
entries, 668–670tables, 636–637
updir function, 688URLs (Uniform Resource Locators), 519–521
hex-encoded characters, 546–547USE command, 869“useDBI” statement, 647use function, 843
modules and pragmas, 378–379use keyword, 326User Datagram Protocol (UDP), 786–787user-defined filehandles, 285–309user-defined functions. See subroutinesuser-defined subroutines, 343–344user/driver program, 442UTF8/UTF16 Unicode support, 281utime function, 709–710, 843
Vvalidating defined functions, 79values
assignment statements, 71call-by-value, 332–338
quigley.book Page 969 Friday, October 12, 2007 1:01 PM
970 Index
values (Continued)defined function, 79fetching, 657hash, sorting by, 124–126hash, variables, 87lists of, 414numeric, relational operators and, 144pack and unpack functions, 106passing to subroutines, 349–354ref function, 418–420return, subroutines, 340–342wantarray function, 343–344
values function, 119, 843VARCHAR(x) data type, 624variables, 69–77
"*", 344$!, 286$$, 727$=, 771$@, 757@*, 778anonymous, 406–407, 428$#arrayname, 81arrays, 80–87assignment statements, 71–72$AUTOLOAD, 354behavior, defining, 494classes, tying to, 493–504complex data structures, 91–93environment
CGI, 531–535CONTENT_LENGTH, 552QUERY_STRING, 544–548
errno, 685global, preventing use of, 336–338hard references. See hard referenceshash, 15, 70, 87–91
arrays, 92–93hashes of hashes, 91–92input, assigning to, 99
importing, 379–385instances, 465lexical, 453naming, 70–71packages, 69–70
PATHEXT, 33PERL5LIB, setting, 373–374predefined, 16quotes, 72–77scalars, 77–80scope, 69–70, 329special, 845–848$_special scalar, 184types, 69
vec function, 844VERSION() method, 462versions of Perl, 3–5viewing
entries, MySQL, 672–677files, storage, 297forms, 538source files, 513
virtual methods, 431, 436–438
WWagner, David, 165wait function, 742–743, 844waiting for client requests, 798waitpid function, 742–743, 844Wall, Larry, 1, 72, 401, 427, 453, 797wantarray function, 343–344, 844warn function, 757, 844warnings pragma, 55–57Web pages. See also HTML
creating, 522–526static and dynamic, 513–515
Web servers. See also serversclient/server databases, 604
Web sites, mod_perl, 927–928Weiman, L., 787-w $file, 319WHERE clause, 630–633WHERE clause (SQL), 876while loops, 177–179
DATA filehandles, 205–208while modifiers, 209whitespace, 34–35
adding, 216metacharacters, 236, 247–249
width of fields, 60
quigley.book Page 970 Friday, October 12, 2007 1:01 PM
Index 971
wildcards, 753–755, 881–883Win32 binary files, 292–293Windows
ActivePerl, 391database servers, 606directories, creating, 695files, 286–290, 689–692hard and soft links, 706passwords, 730–732permissions, 701processes, 723
creating, 744–747environments, 723–725
scripts, startup, 32–33signals, 764
Win32::GetLastError, 756Win32:Process module, 746–747Win32:Spawn module, 745–746words
logical word operators, 151–152printing, 45reserved
databases, 611–612
SQL, 867strict pragma and, 58
Wright, G. R., 788write function, 771, 844writing
dynamic reports, 781–783files, opening for, 291–292operations, 301–302scripts, 31–32
-w switch, 567print function, 55–57
XXAMPP, 614-x $file, 319x modifiers, 216
YYEAR data type, 624y function, 276–280
Z-z $file, 319
quigley.book Page 971 Friday, October 12, 2007 1:01 PM