1. 首页
  2. 编程语言
  3. Perl
  4. Learning Perl, 7th Edition

Learning Perl, 7th Edition

上传者: 2018-12-25 19:11:27上传 PDF文件 5.56MB 热度 42次
Learning Perl, 7th EditionSEVENTH EDITIONLearning PerlMaking easy Things easy andHard Things possibleRandal l. Schwartz, brian d foy, and Tom PhoenixBeijing. Boston. Farnham. Sebastopol. Tokyo OREILLYLearning perlby randal L. Schwartz, brian d foy, and Tom PhoenixCopyright O 2017 Randal L. Schwartz, brian foy, and Tom Phoenix. All rights reservedPrinted in the united states of americaPublished by o reilly media, InC, 1005 Gravenstein Highway North, Sebastopol, CA95472O Reilly books may be purchased for educational, business, or sales promotional use. Online editions arealsoavailableformosttitles(http://safaribooksonline.com).Formoreinformationscontactourcorporateinstitutionalsalesdepartment800-998-9938orcorporate@oreilly.comEditor: Heather SchererIndexer: Lucie haskinsProduction Editor: Melanie YarbroughInterior Designer: David FutatoCopyeditor: Jasmine KwitynCover Designer: Karen MontgomeryProofreader: Sonia arubaIllustrator: rebecca demarestOctober 2016Seventh editionRevision history for the Seventh edition2016-10-05: First releaseSeehttp://oreilly.com/catalog/errata.csp?isbn=9781491954324forreleasedetailsThe O Reilly logo is a registered trademark of O'Reilly Media, Inc. Learning Perl, the cover image, andrelated trade dress are trademarks of o reilly media, incWhile the publisher and the authors have used good faith efforts to ensure that the information andinstructions contained in this work are accurate, the publisher and the authors disclaim all responsibilityfor errors or omissions, including without limitation responsibility for damages resulting from the use ofor reliance on this work. Use of the information and instructions contained in this work is at your ownrisk. If any code samples or other technology this work contains or describes is subject to open sourcelicenses or the intellectual property rights of others, it is your responsibility to ensure that your usethereof complies with such licenses and/or rights978-1-491-95432-4Table of contentsPrefaceXI1. IntroductionQuestions and AnswersIs This the right Book for You?What about the exercises and their answersWhat If im a perl Course Instructor?What Does"Per Stand For?Why Did Larry Create Perl?Why Didnt Larry just Use Some Other Language?1112344457Is Perl easy or Hard?How Did Perl Get to Be So Popular?What's Happening with Perl Now?What's Perl Really Good For?What is perl not good forHow Can i get perl?What IS CPAN?Is There any Kind of Support?What If I Find a bug in perl?10How Do I Make a Perl Program?10A Simple program11What's Inside That Program?13How Do i Compile my perl Program?15A Whirlwind Tour of perl16Exercises2. Scalar dataumbers19All Numbers have the same Format internally20Integer literalsl Integer literals21floatingPoint literals21Numeric Operators22Strings23Single-Quoted String Literals24Double-Quoted String Literals24String Operators25Automatic Conversion Between Numbers and Strings26Perls built-In warnin27Interpreting Nondecimal Numerals28Scalar variables29Choosing Good Variable NamesScalar assignment31Compound assignment Operators31Output with pril32Interpolation of Scalar Variables into Strings32Creating Characters by Code point33Operator Precedence and Associativity34Comparison operators36The if Control Structure37Boolean values37Getting User Input38The chomp operator39The while Control structureThe undef valueThe defined Function41E413. Lists and arrayAccessing Elements of an Array44Special array indices45List literalsle q46List assignment47The pop and push OperatorsThe shift and unshift operators49The splice Operator50Interpolating arrays into Str51The foreach Control Structure52Perls Favorite Default: S53iv Table of ContentsThe reverse Operator53The sort Operator54The each Operator54Scalar and list contextUSing List-Producing Expressions in Scalar Context56Using Scalar-Producing Expressions in List Context58Forcing Scalar Context5 in list context588Exercises594. Subroutines61Defining a Subroutine61Invoking a subroutine62Return valuesArgumentsPrivate Variables in Subroutines66Variable-Length Parameter Lists67a better &max routineEmpty Parameter Lists68Notes on Lexical (my) Variables69The use strict Pragma70The return Operator71Omitting the ampersand72Nonscalar return values74Persistent, Private variablesSubroutine signaturesExercises785. Input and Output.81Input from Standard Input81Input from the Diamond operator83The double diamond85The Invocation ArgumentsOutput to Standard Output86Formatted Output with printf89Arrays and printf91Filehandles91Opening a Filehandle93Binmoding filehandles96Bad Filehandles96Closing a Filehandle97Fatal errors with die97Table of contenWarning Messages with warn9Automatically die-ing99SirngFilehandles100Changing the Default Output Filehandle100Reopening a standard filehand101Output with say102Filehandles in a scalar102Exercises1046. Hashes107What is a hash:107Why Use a Hash?109Hash element access110The hash as a Whole111Hash assignment112The Big Arrow11Hash functions114The keys and values Functions114The each function115Typical Use of a hash116The exists function117The delete function117Hash Element interpolation118The % ENV hash118Exer1197. Regular Expressions.21Sequences121Practice some patterns123e25Quantifiers126routing in Patte130alternatin133Character Clas134Character Class Shortcuts135Negating the Shortcuts137Unicode Properties137Anchors138Word Anchors139Exercises141Table of contents8. Matching with Reqular Expressions143Matches with m//143Match Modifiers144Case-Insensitive Matching with /i144Matching any Character with /sAdding Whitespace with /X145Combining option modifiers146Choosing a Character Interpretation146Beginning and End-of-Line Anchors148Other options149The Binding operator149The match Variables150The Persistence of captures151Noncapturing Parentheses152Named Capt153The Automatic match variables155Preecedence157Examples of Precedence158And Theres more158A Pattern Test Program159Exercises1599. Processing Text with Regular Expressions................... 161Substitutions with s///161Global Replacements with /g162Different delimiters163Substitution modifiers163The Binding Operator163ondestructive substitutions163Case shiftin164Metaquoting166The split Operator166The join Function168m// in List context168More Powerful Regular Expressions169Nongreedy Quantifiers169Fancier word boundaries170Matching Multiple-Line Text172Updating many files172In-Place Editing from the Command Line174Exercises176Table of( ontents|ⅶi10. More Control structuresThe unless control structure177The else clause with unle178The until Control Structure178Statement modifiers179The Naked Block Control Structure180The elsif Clause181Autoincrement and autodecrement182The Value of autoincrement182The for Control structure183The Secret Connection Between foreach and for185Loop controls186The last Operator186The next Operator187The redo Operator188Labeled blocks189The Conditional OperatorLogical Operators191The Value of a short-Circuit Operator192The defined-or Operator193Control Structures Using Partial-Evaluation Operators194Exercises1961. Perl modules197Finding modules197Installing Modules198Using Your Own Directories199Using Simple modules201The file, Basename Module202Using Only Some Functions from a Module203The File: Spec Module204Path: Class205Databases and dbi205Dates and Ti206Exercises20712. File tests209File Test Operators209Testing Several Attributes of the Same File213Stacked File Test Operators214The stat and lstat Functions216The localtime function217I Table of Contents
用户评论