Cover image for Mastering Perl 5
Title:
Mastering Perl 5
Author:
Herrmann, Eric.
Personal Author:
Publication Information:
San Francisco : Sybex, [1999]

©1999
Physical Description:
xxxi, 926 pages : illustrations ; 23 cm
General Note:
Includes index.
Language:
English
ISBN:
9780782122008
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Central Library QA76.73.P22 H47 1999 Adult Non-Fiction Central Closed Stacks
Searching...

On Order

Summary

Summary

"Mastering Perl 5" is designed to take the fear out of Unix and Perl, covering the key features of Perl for NT and teaching readers the secret behind programming it quickly and easily


Author Notes

Eric C. Herrmann is president of Application Software Solutions, Inc. (ASSI), which builds business Internet solutions in Perl, Java Script, and other languages. The author of the best-selling Teach Yourself CGI Programming With Perl 5 in a Week, he has an MS in computer science and more than ten years of programming experience.


Table of Contents

Introductionp. xxiii
Part I A Quick Start to Perl Programming
1 Writing Your First Programp. 3
Introducing Perl 5p. 4
The Evolution of Perlp. 4
A Perl Programp. 6
Perl as an Interpreted Languagep. 7
Windows, Unix, and Perlp. 9
Running Perl Programsp. 11
Using the MS-DOS Windowp. 11
Using the Unix Command Shellp. 16
Using Programmer's Editorsp. 20
Choosing a Windows Editorp. 21
Choosing a Unix Editorp. 23
Modifying a Programp. 25
Understanding Perl Syntax Basicsp. 27
Perl Program Structurep. 27
Perl Program Componentsp. 28
Writing a CGI Programp. 30
Defining CGIp. 31
Understanding the Client/Server Interface Modelp. 32
Understanding HTTP Communicationsp. 33
Configuring the Web Serverp. 36
Writing the Registration Formp. 38
Creating the CGI Programp. 41
Installing CGI Programsp. 44
Understanding How a CGI Program Worksp. 45
Summaryp. 50
2 Debugging Your Programsp. 53
Handling Syntax Errorsp. 55
Pinpointing Syntax Errorsp. 55
Understanding Error Messagesp. 58
Avoiding Errorsp. 63
Turning On Warning Messagesp. 63
Avoiding Misspelled Variable Namesp. 63
Following Good Coding Practicesp. 64
Testing Loop and Conditional Expressionsp. 65
Avoiding Common Perl 5 Mistakesp. 67
Handling Runtime Errorsp. 70
Using the System Error Variablep. 70
Inserting print Statementsp. 72
Searching for Bugsp. 73
Using a Debuggerp. 73
Running the Perl Debuggerp. 74
Debugging Using Emacsp. 81
Running the ActiveState Windows Debuggerp. 83
Debugging CGI Programsp. 85
Running the Program with Test Datap. 86
Adding print Statementsp. 87
Summaryp. 89
Part II Perl Programming Fundamentals
3 Jump-Start on Programming Fundamentalsp. 95
Jump-Start Definitionsp. 96
Jump-Start Programp. 100
Operators and Contextp. 106
Variablesp. 108
Variable Namesp. 109
Namespaces and Variable Declarationsp. 110
Scalar Variablesp. 111
Arraysp. 113
Hashesp. 115
Referencesp. 118
Control Structuresp. 123
The if Familyp. 123
The SWITCH Constructp. 125
The for Loopp. 127
The foreach Loopp. 128
The while and until Loopsp. 129
What Next?p. 130
4 Operators and Programming Fundamentalsp. 133
Perl 5 and Contextp. 134
Numeric Operationsp. 135
Basic Numeric Operationsp. 135
The Assignment Operatorp. 137
Compound Assignment Operatorsp. 138
Increment and Decrement Operatorsp. 141
Boolean Operationsp. 143
String Operationsp. 147
String Comparisonsp. 150
ASCII Charactersp. 151
Boolean Combination Operationsp. 155
The Logical AND Operatorp. 156
The Logical OR Operatorp. 158
The Logical NOT Operatorp. 158
Binary Operationsp. 160
Binary Numbersp. 160
Hexadecimal Numbersp. 163
Binary Operatorsp. 164
Precedence and Associativityp. 167
Summaryp. 170
5 Scalar Datap. 173
An Introduction to Scalar Variablesp. 174
What's a Scalar Variable?p. 175
Scalar Variable Namesp. 176
What's a Literal?p. 177
Strings and Character Datap. 177
Quotation Marksp. 178
The Quote Operatorsp. 184
Rules for String Literalsp. 187
Numeric Literalsp. 187
Numeric Formatsp. 189
Fixed-Point Number Solutionsp. 189
Boolean Valuesp. 195
Variable Declarationsp. 196
Variables and Namespacesp. 197
The my and local Keywordsp. 198
The Case against Recycled Variablesp. 199
Scalar Context versus List Contextp. 199
Summaryp. 203
6 Arrays and Hashesp. 205
An Introduction to Arraysp. 206
Array Data Storage and Retrievalp. 208
Array Cell Assignmentp. 208
Array List Assignmentp. 211
Array Sizingp. 213
Array Data Retrievalp. 217
Array Slicesp. 218
Built-In Functions for Working with Arraysp. 222
Stack and Queue Functionsp. 222
List Modification with the splice Functionp. 227
Array Sorting Functionsp. 228
An Introduction to Hashesp. 230
Hash Data Storage and Retrievalp. 231
Hash Keysp. 232
Hash Value Retrievalp. 235
Built-In Functions for Working with Hashesp. 236
Key Retrieval Functionsp. 236
Item Removal with the delete Functionp. 241
Item Verification with the exists Functionp. 241
Summaryp. 241
7 Referencesp. 245
An Introduction to Referencesp. 246
Reference Operatorsp. 248
Types of Reference Variablesp. 248
Direct References and Dereferencingp. 251
Direct Scalar Referencesp. 252
Direct Array Referencesp. 254
Direct Hash Referencesp. 257
A Quick Recapp. 257
Dereferencing Alternativesp. 258
Curly Bracesp. 258
The Right Arrow Operatorp. 259
Square Bracketsp. 259
Multi-Dimensional Arraysp. 260
Three-Dimensional Array Dereferencingp. 264
The Last Cell Index for Loop Controlp. 264
Multi-Dimensional Arrays as Indexesp. 265
Anonymous Arrays and Hashesp. 266
Summaryp. 269
8 Conditional Statementsp. 271
An Introduction to Branching Statementsp. 272
Simple Conditional Expressionsp. 273
Blocks of Statementsp. 274
Complex Conditional Expressionsp. 275
Good Coding Practicesp. 276
Commenting Your Codep. 276
Indentingp. 278
Using Variable Names as Array Indexesp. 279
The if Familyp. 281
if else Statementsp. 282
if elsif else Statementsp. 284
Nested if Clauses versus elsif Clausesp. 286
Switch Simulationp. 293
Labelsp. 299
The split Functionp. 300
if Blocks versus Simulated switch Statementsp. 301
The Ternary Operatorp. 305
Summaryp. 306
9 Loopsp. 309
An Introduction to Loopsp. 310
while/until Loops and do Statementsp. 312
while Loopsp. 312
until Loopsp. 316
The do Statementp. 317
The for and foreach Loopsp. 322
for Loopsp. 322
foreach loopsp. 326
Array References in Loopsp. 339
Loop Modifiersp. 343
The continue Blockp. 343
The last Commandp. 344
nextp. 345
The redo Commandp. 346
Summaryp. 347
Part III Input and Output Handling
10 Jump-Start on Input/Outputp. 351
Jump-Start Definitionsp. 352
Jump-Start Programp. 354
Command-Line Inputp. 356
File Inputp. 358
Opening a Filep. 358
Reading from a Filep. 360
File Outputp. 362
Outputting Program Datap. 362
Setting and Closing File Handlesp. 363
Formatting Output Datap. 364
Directoriesp. 365
Reading a Directoryp. 365
Creating, Deleting, and Changing Directoriesp. 366
File and Directory Modulesp. 367
What Next?p. 368
11 Input and Output Basicsp. 371
Command-Line Inputp. 372
Command-Line Argumentsp. 373
Command-Line Switchesp. 381
Opening Filesp. 388
Parts of a Filenamep. 388
File Handlesp. 390
The open Functionp. 391
Moving through Filesp. 393
Positioning with the seek Functionp. 394
Reading the File into an Arrayp. 396
Modifying Filesp. 397
Using the Hard Disk as Workspacep. 399
Using Memory as Workspacep. 401
Closing Filesp. 403
Appending Datap. 403
Deleting a Filep. 403
Using File Test Operatorsp. 405
File Privileges Testsp. 410
File Type Testsp. 412
File Existence and Size Testsp. 413
File Modification Testsp. 413
Unix File Handle Type Testsp. 414
Summaryp. 414
12 Printing and Formatting Techniquesp. 417
Using the print Functionp. 418
Setting the Default File Handlep. 419
Using the Heredoc Operatorp. 420
Using Print Formatting Functionsp. 423
Formatting with printf and sprintfp. 423
Using Print Escape Sequencesp. 429
Printing Arraysp. 430
Writing Formatted Outputp. 432
Naming Formatsp. 435
Defining Format Outputp. 435
Formatting with Special Variablesp. 437
Handling Long Data Itemsp. 439
Summaryp. 442
13 Directories and System I/O Utilitiesp. 445
Directory Modules and Functionsp. 446
Working with Directoriesp. 448
Working with Directory Handlesp. 452
File Functionsp. 456
Opening a Filep. 457
Reading and Writing to a Filep. 458
Getting and Setting File Informationp. 460
Using Unix-Only Functionsp. 469
File Modulesp. 470
Platform-Independent File Symbolsp. 472
Platform-Independent Copying and Movingp. 473
I/O Interfacesp. 474
A File System Operations Interfacep. 479
Summaryp. 479
Part IV Data Manipulation
14 Jump-Start on String Functions and Regular Expressionsp. 485
Jump-Start Definitionsp. 486
Jump-Start Programp. 488
String Functionsp. 490
The length Functionp. 492
The split Functionp. 492
The translate Functionp. 493
The substitute Functionp. 493
The index Functionp. 494
The substr Functionp. 494
Character-Case Functionsp. 494
Regular Expressionsp. 495
The Pattern-Match Functionp. 496
Elements of Regular Expressionsp. 496
A Regular Expression Examplep. 499
What Next?p. 502
15 String Manipulationp. 505
Working with String Partsp. 506
Getting the First and Last Position of a Substringp. 506
Extracting Substringsp. 508
Getting the String's Lengthp. 509
Replacing Stringsp. 511
Changing Charactersp. 513
Translating between Numbers and Charactersp. 513
Changing Casep. 518
Translating Single Charactersp. 521
Removing End-of-Line Charactersp. 522
Separating and Joining Stringsp. 524
Splitting Stringsp. 524
Joining Strings Togetherp. 529
Packing Charactersp. 530
Creating Sorting Subroutinesp. 534
Using Comparison Operatorsp. 535
Sorting a Hash by Valuep. 537
Sorting under Multiple Conditionsp. 538
Summaryp. 542
16 Regular Expressionsp. 545
An Introduction to Regular Expressionsp. 546
The Functions for Matching Patternsp. 546
Matches in Conditional Expressionsp. 548
Regular Expression Componentsp. 549
Meta-Charactersp. 550
Atomsp. 551
Rules for Building Regular Expressionsp. 552
Pattern-Match Variablesp. 565
Pattern Modifiersp. 568
Global Matchesp. 568
Ignore Case Matchesp. 569
Multiple and Single Line Matchesp. 570
Only Once Pleasep. 571
Extra Spaces and Commentsp. 572
Regular Expression Examplesp. 573
A Simple Patternp. 573
A Whole Word Matchp. 574
Electronic Commerce Patternsp. 576
A Globally Lazy Matchp. 581
Summaryp. 584
Part V Advanced Perl Programming
17 Jump-Start on Advanced Programming Conceptsp. 589
Jump-Start Definitionsp. 590
Jump-Start Programp. 594
Packagesp. 598
Package Namespacesp. 598
Qualified and Unqualified Namesp. 599
Data Scopep. 600
Global Scopep. 601
Dynamic Scopep. 602
Lexical Scopep. 602
Subroutinesp. 603
Subroutine Callsp. 603
Subroutine Parametersp. 604
Subroutine Return Valuesp. 606
Object-Oriented Perl 5p. 606
Object Methodsp. 607
Object Variablesp. 609
Inheritancep. 610
E-Mail Transferp. 611
What Next?p. 613
8 Functional Programmingp. 615
Packagesp. 616
Package Definitionp. 617
Symbol Tablesp. 622
Data Scopep. 628
Global Scopep. 629
Dynamic Scopep. 630
Lexical Scopep. 632
Subroutines and Functionsp. 636
Subroutine Definitionp. 636
Subroutine Calling Syntaxp. 637
Subroutine Parameter Listsp. 639
Returning Datap. 643
Summaryp. 645
19 Object-Oriented Programmingp. 649
An Introduction to Objects and Classesp. 650
Object Characteristicsp. 650
Object Classesp. 651
Object Methodsp. 651
Class Methodsp. 652
Constructorsp. 652
Object Reference Variablesp. 654
Instance Methodsp. 658
Object Variablesp. 662
Instance Variablesp. 663
Class Variablesp. 668
Destructorsp. 669
Named Parametersp. 671
Inheritancep. 675
Summaryp. 681
20 E-Mail Solutionsp. 685
An Introduction to E-Mail Programs and Protocolsp. 686
The sendmail Programp. 687
SMTP Serversp. 688
Unix E-Mail Solutionsp. 691
A Registration Applicationp. 691
A Mailing List Applicationp. 699
Windows E-Mail Solutionsp. 702
Blat: A Windows E-Mail Programp. 703
Sender.pm: A Perl E-Mail Interfacep. 708
Summaryp. 724
Part VI Windows Only
21 Jump-Start on Windows Solutionsp. 729
Jump-Start Definitionsp. 730
Jump-Start Programp. 732
Windows System Informationp. 739
Drive Informationp. 739
File System Informationp. 740
User Informationp. 741
Network Informationp. 743
Registry Informationp. 745
Event Log Informationp. 747
Perl and Your Windows Databasep. 749
The Database Interfacep. 750
SQL Statementsp. 752
What Next?p. 754
22 Win32 System Administrationp. 757
Win32 Extensionsp. 758
The Disk Drivep. 762
Getting the Drivesp. 762
Getting the Disk Configurationp. 764
The File Systemp. 768
User Informationp. 773
Getting Login Informationp. 773
Getting User Detailsp. 775
Network Administrationp. 780
Building a Network Diagnostic Utilities Interfacep. 780
Managing Physical Addressesp. 786
Configuring TCP/IPp. 787
Getting NetBIOS Statisticsp. 789
Using PINGp. 791
Getting Network Routing Tablesp. 793
Tracing Internet Routesp. 795
DLL Functionsp. 797
Summaryp. 800
23 The Registry and Event Logp. 803
An Introduction to the Registryp. 804
Running the Registry Editorp. 804
Backing Up Your Registryp. 806
Registry Manipulationp. 807
Reading the Registryp. 807
Creating a Registry Keyp. 812
Deleting Registry Keysp. 814
Getting Registry Datap. 816
Modifying Registry Datap. 819
An Introduction to the Event Logp. 821
Event Log Manipulationp. 823
Reading the Event Logp. 824
Writing to the Event Logp. 831
Using Other EventLog Methodsp. 833
Extending the EventLog Classp. 835
Summaryp. 841
24 Databases and the Webp. 843
An Introduction to Databasesp. 844
The ODBC Connectionp. 845
Creating a DSNp. 846
The Win32::ODBC Modulep. 853
Existing Datap. 858
Creating a Database Tablep. 858
Importing Text Datap. 860
SQL--The Database Languagep. 863
Creating a Tablep. 865
Modifying a Tablep. 868
Inserting Data into a Tablep. 869
Deleting Data from a Tablep. 870
Updating Data in a Tablep. 872
Selecting Data from a Tablep. 872
Your Database and the Internetp. 873
Setting Up for Access and the Webp. 874
Initializing the Transportation Databasep. 876
Importing Data into the Transportation Databasep. 880
Searching for Cars on the Webp. 885
Displaying the Online Search Resultsp. 888
Summaryp. 894
Indexp. 895

Google Preview