Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 2.399 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
2.399
Dung lượng
11,61 MB
Nội dung
Perl by Example, Fourth Edition by Ellie Quigley Publisher: Prentice Hall Pub Date: November 05, 2007 Print ISBN-10: 0-13-238182-6 Print ISBN-13: 978-0-13-238182-6 Pages: 1008 Table of Contents | Index Overview "I picked up a copy of JavaScript by Example over the weekend and wanted to thank you for putting out a book that makes JavaScript easy to understand I've been a developer for several years now and JS has always been the "monster under the bed," so to speak Your book has answered a lot of questions I've had about the inner workings of JS but was afraid to ask Now all I need is a book that covers Ajax and Coldfusion Thanks again for putting together an outstanding book." –Chris Gomez, Web services manager, Zunch Worldwide, Inc "I have been reading your UNIX® Shells by Example book, and I must say, it is brilliant Most other books do not cover all the shells, and when you have to constantly work in an organization that uses tcsh, bash, and korn, it can become very difficult However, your book has been indispensable to me in learning the various shells and the differences between them…so I thought I'd email you, just to let you know what a great job you have done!" –Farogh-Ahmed Usmani, B.Sc (Honors), M.Sc., DIC, project consultant (Billing Solutions), Comverse "I have been learning Perl for about two months now; I have a little shell scripting experience but that is it I first started with Learning Perl by O'Reilly Good book but lacking on the examples I then went to Programming Perl by Larry Wall, a great book for intermediate to advanced, didn't help me much beginning Perl I then picked up Perl by Example, Third Edition–this book is a superb, well-written programming book I have read many computer books and this definitely ranks in the top two, in my opinion The examples are excellent The author shows you the code, the output of each line, and then explains each line in every example." –Dan Patterson, software engineer, GuideWorks, LLC "Ellie Quigley has written an outstanding introduction to Perl, which I used to learn the language from scratch All one has to do is work through her examples, putz around with them, and before long, you're relatively proficient at using the language Even though I've graduated to using Programming Perl by Wall et al., I still find Quigley's book a most useful reference." –Casey Machula, support systems analyst, Northern Arizona University, College of Health and Human Services "When I look at my bookshelf, I see eleven books on Perl programming Perl by Example, Third Edition, isn't on the shelf; it sits on my desk, where I use it almost daily When I bought my copy I had not programmed in several years and my programming was mostly in COBOL so I was a rank beginner at Perl I had at that time purchased several popular books on Perl but nothing that really put it together for me I am still no pro, but my book has many dog-eared pages and each one is a lesson I have learned and will certainly remember "I still think it is the best Perl book on the market for anyone from a beginner to a seasoned programmer using Perl almost daily." –Bill Maples, network design tools and automations analyst, Fidelity National Information Services "We are rewriting our intro to OS scripting course and selected your text for the course It's an exceptional book The last time we considered it was a few years ago (second edition) The debugging and system administrator chapters at the end nailed it for us." –Jim Leone, Ph.D., professor and chair, Information Technology, Rochester Institute of Technology "Quigley's book acknowledges a major usage of PHP To write some kind of front end user interface program that hooks to a back end MySQL database Both are free and open source, and the combination has proved popular Especially where the front end involves making an HTML web page with embedded PHP commands "Not every example involves both PHP and MySQL Though all examples have PHP Many demonstrate how to use PHP inside an HTML file Like writing user-defined functions, or nesting functions Or making or using function libraries The functions are a key idea in PHP, that take you beyond the elementary syntax Functions also let you gainfully use code by other PHP programmers Important if you are part of a coding group that has to divide up the programming effort in some manner." –Dr Wes Boudville, CTO, Metaswarm Inc The World's Easiest Perl Tutorial–Fully Updated! Perl by Example, Fourth Edition, is the easiest, most handson way to learn Perl Legendary Silicon Valley programming instructor Ellie Quigley has thoroughly updated her classic to deliver the skills and information today's Perl users need most– including all-new coverage of MySQL database programming and a Perl QuickStart designed to get experienced users up and running fast Quigley illuminates every technique with focused, classroomtested code examples, detailed line-by-line explanations, and real program output This exceptionally clear, easy-tounderstand book takes you from your first Perl script to database-driven applications It's the only Perl book you'll ever need! New in this edition: Perl programming QuickStart: makes first-time Perl programmers productive in just twenty pages All-new chapter on using the Perl DBI with the MySQL database–plus an easy SQL primer to quickly get you started programming any database New introductions to Perl in biology (bioinformatics) and to mod_perl, a Perl interpreter embedded in the Apache server, which allows you to create fast, dynamic content; manage the Apache server; authenticate users; and much more Completely updated: Includes many new and completely rewritten code examples Contains fully revised CGI coverage for building dynamic Web sites with Perl Covers modern Perl 5.8 concepts and principles–and provides a great foundation for Perl 6 More than 30,000 sysadmins, power users, and developers have used previous editions of Perl by Example to become expert Perl programmers With Perl by Example, Fourth Edition, you can, too–even if you're completely new to Perl After you've become an expert, you'll turn to this book constantly as the best source for reliable answers, solutions, and code About the CD-ROM: The CD-ROM includes all code and files for this book's hundreds of example scripts Perl by Example, Fourth Edition by Ellie Quigley Publisher: Prentice Hall Pub Date: November 05, 2007 Print ISBN-10: 0-13-238182-6 Print ISBN-13: 978-0-13-238182-6 Pages: 1008 Table of Contents | Index Copyright Praise for Ellie Quigley's Books Preface Acknowledgments Chapter 1 The Practical Extraction and Report Language Section 1.1 What Is Perl? Section 1.2 What Is an Interpreted Language? Section 1.3 Who Uses Perl? Section 1.4 Where to Get Perl Section 1.5 What Is CPAN? Section 1.6 Perl Documentation Section 1.7 What You Should Know Section 1.8 What's Next? Chapter 2 Perl Quick Start Section 2.1 Quick Start, Quick Reference Section 2.2 Chapter Summary Section 2.3 What's Next? Chapter 3 Perl Scripts Section 3.1 Script Setup Section 3.2 The Script Section 3.3 Perl at the Command Line Section 3.4 What You Should Know Section 3.5 What's Next? Chapter 4 Getting a Handle on Printing Section 4.1 The Filehandle Section 4.2 Words Section 4.3 The print Function Section 4.4 The printf Function Section 4.5 What You Should Know Section 4.6 What's Next? Chapter 5 What's in a Name Section 5.1 About Perl Variables Section 5.2 Scalars, Arrays, and Hashes Section 5.3 Reading from STDIN Section 5.4 Array Functions Section 5.5 Hash (Associative Array) Functions Section 5.6 More Hashes Section 5.7 What You Should Know Section 5.8 What's Next? Chapter 6 Where's the Operator? Section 6.1 About Perl Operators Section 6.2 Mixing Data Types Section 6.3 Precedence and Associativity Section 6.4 What You Should Know Section 6.5 What's Next? Chapter 7 If Only, Unconditionally, Forever Section 7.1 Control Structures, Blocks, and Compound Statements Section 7.2 Repetition with Loops Section 7.3 What You Should Know Section 7.4 What's Next? Chapter 8 Regular Expressions—Pattern Matching Section 8.1 What Is a Regular Expression? Section 8.2 Expression Modifiers and Simple Statements Section 8.3 Regular Expression Operators Section 8.4 What You Should Know Section 8.5 What's Next? Chapter 9 Getting Control—Regular Expression Metacharacters Section 9.1 Regular Expression Metacharacters Section 9.2 Unicode Section 9.3 What You Should Know Section 9.4 What's Next? Chapter 10 Getting a Handle on Files Section 10.1 The User-Defined Filehandle Section 10.2 Passing Arguments Section 10.3 File Testing Section 10.4 What You Should Know Section 10.5 What's Next? Chapter 11 How Do Subroutines Function? Section 11.1 Subroutines/Functions Section 11.2 Passing Arguments Section 11.3 Call-by-Reference Section 11.4 What You Should Know Section 11.5 What's Next? Chapter 12 Modularize It, Package It, and Send It to the Library! Section 12.1 Packages and Modules Section 12.2 The Standard Perl Library Section 12.3 Modules from CPAN Section 12.4 What You Should Know Section 12.5 What's Next? Chapter 13 Does This Job Require a Reference? Section 13.1 What Is a Reference? What Is a Pointer? Section 13.2 What You Should Know Section 13.3 What's Next? Chapter 14 Bless Those Things! (Object-Oriented Perl) Section 14.1 The OOP Paradigm Section 14.2 Classes, Objects, and Methods Section 14.3 Anonymous Subroutines, Closures, and Privacy Section 14.4 Inheritance Section 14.5 Public User Interface—Documenting Classes Section 14.6 Using Objects from the Perl Library Section 14.7 What You Should Know Section 14.8 What's Next? Chapter 15 Those Magic Ties and DBM Stuff Section 15.1 Tying Variables to a Class Section 15.2 DBM Files Section 15.3 What You Should Know Section 15.4 What's Next? Chapter 16 CGI and Perl: The Hyper Dynamic Duo Section 16.1 Static and Dynamic Web Pages Section 16.2 How It all Works Section 16.3 Creating a Web Page with HTML Section 16.4 How HTML and CGI Work Together Section 16.5 Getting Information Into and Out of the CGI Script Section 16.6 CGI and Forms Section 16.7 The CGI.pm Module Chapter 17 Perl Meets MySQL—A Perfect Connection Section 17.1 Introduction Section 17.2 What Is a Relational Database? Section 17.3 Getting Started with MySQL Section 17.4 What Is the Perl DBI? Section 17.5 Statements that Don't Return Anything Section 17.6 Transactions Section 17.7 Using CGI and the DBI to Select and Display Entries Section 17.8 What's Left? Section 17.9 What You Should Know Section 17.10 What's Next? Chapter 18 Interfacing with the System Section 18.1 System Calls Section 18.2 Processes Section 18.3 Other Ways to Interface with the Operating System Section 18.4 Error Handling Section 18.5 Signals Section 18.6 What You Should Know Section 18.7 What's Next? Chapter 19 Report Writing with Pictures Section 19.1 The Template Section 19.2 What You Should Know Section 19.3 What's Next? Chapter 20 Send It Over the Net and Sock It to 'Em! Section 20.1 Networking and Perl Section 20.2 Client/Server Model Section 20.3 Network Protocols (TCP/IP) Section 20.4 Network Addressing Section 20.5 Sockets Section 20.6 Client/Server Programs Section 20.7 The Socket.pm Module Section 20.8 What You Should Know Appendix A Perl Built-ins, Pragmas, Modules, and the Debugger Section A.1 Perl Functions Section A.2 Special Variables Section A.3 Perl Pragmas Section A.4 Perl Modules Section A.5 Command-Line Switches references return values user-defined subs function substitutions commands delimiters, modifying global newline (//n) character substr function subtraction operator (-) superusers suppression indicator switches -c command-line 2nd 3rd -c -e -n -i -w print function Switch.pm module switch statements symbolic references hard references, comparing to strict pragma symbols encoding fields designator display importing metasymbols tables 2nd symlink function 2nd syntax :: errors testing with -c switch syscall function 2nd 3rd sysopen function sysread function 2nd sysseek function SYSTEM attribute system calls directories accessing creating deleting modifying searching files low-level I/O modifying renaming statistics hard and soft links packing and unpacking data permissions system directories and file attributes system errors [See also errors.] system files accessing system function 2nd syswrite function 2nd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] tables adding with primary keys altering CREATE TABLE statement creating data, inserting databases dropping 2nd joining modifying MySQL privilege system sorting SQL symbols 2nd updating tags, HTML creating forms TCP/IP 2nd telldir function 2nd tell function 2nd 3rd telnet protocol templates [See also prototypes.] pack and unpack functions reports defining dynamic report writing filehandles, modifying filling fields multiline fields select function top-of-the-page formatting TEMPORARY attribute Terminal application (MySQL) terminating SQL statements 2nd testing eof function files forms at the command-line syntax with -c switch text fields files, opening TEXTAREA type TEXT data type text editors HTML, creating Web pages in searching textfield() method TEXT type -T $file -t $file tied function tie function 2nd Tie::Scalar package tilde () time formatting and processes TIME: hh-mm-ss data type time function 2nd times function 2nd TIMESTAMP data type TINYBLOB data type TINYINT data type TINYTEXT data type TITLE element tmpdir function tools GUIs, MySQL h2xs phpMyAdmin (MySQL) privilege system (MySQL) top-of-the-page formatting tracking cookies transactions, MySQL translators pod pod files Transmission Control Protocol (TCP) tr function 2nd truncate function turning off capturing case sensitivity 2nd greediness 2nd tying arrays hashes scalars variables to classes typeglobs 2nd symbol tables types data [See also data types.] of errors of input for forms of joins of literals of methods MIME o of inheritance of operators pack and unpack functions of sockets of text editors of variables Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] ucfirst function uc function -u $file uid umask function undef function 2nd 3rd Unicode Unicode Consortium Uniform Resource Locators [See URLs (Uniform Resource Locators).] UNIVERSAL class UNIVERSAL method UNIX commands [See commands.] database servers directories 2nd domains files 2nd hard and soft links kernels passwords permissions processes creating environments scripts scripts, startup sendmail program sockets unless constructs unless modifiers unless statements unlink function 2nd unmask function unnamed methods, calling unpack function 2nd unpacking data unshift function 2nd untie function 2nd until loops until modifiers UPDATE command updating entries tables updir function URLs (Uniform Resource Locators) hex-encoded characters USE command "useDBI" statement use function modules and pragmas use keyword User Datagram Protocol (UDP) user-defined filehandles user-defined functions [See subroutines.] user-defined subroutines user/driver program UTF8/UTF16 Unicode support utime function 2nd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] validating defined functions values assignment statements call-by-value defined function fetching hash, sorting by hash, variables lists of numeric, relational operators and pack and unpack functions passing to subroutines ref function return, subroutines wantarray function values function 2nd VARCHAR(x) data type variables "*" $! $$ $= $@ @* anonymous 2nd $#arrayname arrays assignment statements $AUTOLOAD behavior, defining classes, tying to complex data structures environment CGI CONTENT_LENGTH QUERY_STRING errno global, preventing use of hard references [See hard references.] hash 2nd 3rd arrays hashes of hashes input, assigning to importing instances lexical naming packages PATHEXT PERL5LIB, setting predefined quotes scalars scope 2nd special $_special scalar types vec function VERSION() method versions of Perl viewing entries, MySQL files, storage forms source files virtual methods 2nd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Wagner, David wait function 2nd waiting for client requests waitpid function 2nd Wall, Larry 2nd 3rd 4th 5th 6th wantarray function 2nd warn function 2nd warnings pragma Web pages [See also HTML (Hypertext Markup Language).] creating static and dynamic Web servers [See also servers.] client/server databases Web sites, mod_perl Weiman, L -w $file WHERE clause WHERE clause (SQL) while loops DATA filehandles while modifiers whitespace adding metacharacters 2nd width of fields wildcards 2nd Win32 binary files Windows ActivePerl database servers directories, creating files 2nd hard and soft links passwords permissions processes creating environments scripts, startup signals Win32::GetLastError Win32:Process module Win32:Spawn module words logical word operators printing reserved databases SQL strict pragma and Wright, G R write function 2nd writing dynamic reports files, opening for operations scripts -w switch print function Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] XAMPP -x $file x modifiers Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] YEAR data type y function Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] -z $file ... The CD-ROM includes all code and files for this book's hundreds of example scripts Perl by Example, Fourth Edition by Ellie Quigley Publisher: Prentice Hall Pub Date: November 05, 2007 Print ISBN- 10: 0-13-238182-6 Print ISBN- 13: 978-0-13-238182-6... More than 30,000 sysadmins, power users, and developers have used previous editions of Perl by Example to become expert Perl programmers With Perl by Example, Fourth Edition, you can, too–even if you're completely new to Perl After you've become an expert, you'll... how far you want to go with Perl If nothing else, Perl is fun! 1.3.1 Which Perl? Perl has been through a number of revisions There are two major versions of Perl: Perl 4 and Perl 5 The last version of Perl 4 was Perl 4, patchlevel 36 (Perl 4.036), released in 1992,