Beginning Perl

( 1 )

Overview

Everything beginners need to start programming with Perl

Perl is the ever-popular, flexible, open source programming language that has been called the programmers’ Swiss army knife. This book introduces Perl to both new programmers and experienced ones who are looking to learn a new language. In the tradition of the popular Wrox Beginning guides, it presents step-by-step guidance in getting started, a host of try-it-out exercises, real-world ...

See more details below
Paperback
$28.87
BN.com price
(Save 27%)$39.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (19) from $13.96   
  • New (11) from $14.99   
  • Used (8) from $13.96   

Overview

Everything beginners need to start programming with Perl

Perl is the ever-popular, flexible, open source programming language that has been called the programmers’ Swiss army knife. This book introduces Perl to both new programmers and experienced ones who are looking to learn a new language. In the tradition of the popular Wrox Beginning guides, it presents step-by-step guidance in getting started, a host of try-it-out exercises, real-world examples, and everything necessary for a Perl novice to start programming with confidence.

  • Introduces Perl to both new programmers and experienced ones who want to learn a new language
  • Provides a host of real-world applications for today's environments so readers can get started immediately
  • Covers the new features of Perl but fully applicable to previous editions

Beginning Perl provides the information and instruction you need to confidently get started with Perl.

For Instructors: Classroom and training support material are available for this book.

Read More Show Less

Product Details

  • ISBN-13: 9781118013847
  • Publisher: Wiley
  • Publication date: 9/19/2012
  • Edition number: 1
  • Pages: 744
  • Sales rank: 635,588
  • Product dimensions: 7.40 (w) x 9.20 (h) x 1.40 (d)

Meet the Author

Curtis "Ovid" Poe has specialized in Perl since 2000. He is an author, a regular guest speaker at conferences across Europe and the United States, and he wrote the test harness that currently ships with the Perl language.

Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved.

Read More Show Less

Table of Contents

INTRODUCTION xxiii

CHAPTER 1: WHAT IS PERL? 1

Perl Today 2

Getting Perl 3

Working with Non-Windows Platforms: perlbrew 4

Using Windows 6

The Perl Community 8

IRC 8

PerlMonks 9

Perl Mongers 9

StackOverflow 9

Using perldoc 11

Understanding the Structure of perldoc 11

Getting Started with perldoc 11

Using Tutorials and FAQs 12

Using the perldoc -f function 14

Using a Terminal Window 14

Using the Command Line 15

Creating a Work Directory 16

Creating Hello, World! 18

Writing Your First Program 18

Shebang Lines 21

Summary 22

CHAPTER 2: UNDERSTANDING THE CPAN 25

CPAN and METACPAN 26

Finding and Evaluating Modules 27

Downloading and Installing 29

CPAN Clients 33

Using the CPAN.pm Client 33

Using the Cpanm Client 35

PPM 36

CPAN::Mini 36

Summary 39

CHAPTER 3: VARIABLES 41

What Is Programming? 42

A Few Things to Note Before Getting Started 43

strict, warnings, and diagnostics 43

The my Function 43

Sigils 44

Identifiers 45

Scalars 46

Strings 47

Numbers 51

Arrays 53

Breaking Down the Code 54

Accessing Elements 55

Iterating over Arrays 58

Hashes 58

Accessing Elements 59

Iterating Over Hashes 60

Adding Data to Hashes 60

Slices 61

Array Slices 62

Hash Slices 62

Context 63

Scalar Context 63

List Context 64

Scope 67

my Variables 67

Package Variables 69

Strict, Warnings, and Diagnostics 72

strict 74

warnings 74

diagnostics 75

Working Without a Net 76

Perl’s Built-in Variables 78

$_ 78

%ENV 79

@ARGV 79

Other Special Variables 80

Summary 81

CHAPTER 4: WORKING WITH DATA 83

Using Scalars 84

Working with Strings 85

Using String Operators 94

Scalar::Util 97

Numeric Builtins 98

Bitwise Operators 103

Understanding Booleans 103

Assignment Operators 108

Precedence and Associativity 109

Array and List Functions 111

Built-in Array Functions 111

List::Util 116

Built-in Hash Functions 116

delete() 116

exists() 117

keys() 117

values() 117

each() 117

Scoping Keywords 119

my() 119

local() 119

our() 120

state() 120

Summary 121

CHAPTER 5: CONTROL FLOW 125

Using the if Statement 126

Understanding Basic Conditionals 126

else/elsif/unless 128

The Ternary Operator ?: 131

for/foreach loops 132

Arrays 132

Lists 135

C-Style 136

Using while/until Loops 142

Lists 143

last/next/redo/continue 144

Labels 146

Statement Modifiers 147

Types of Statement Modifiers 147

do while/do until 149

given/when 151

Basic Syntax 151

The Switch Module 153

Summary 154

CHAPTER 6: REFERENCES 157

References 101 158

Array References 158

Hash References 159

Anonymous References 160

Other References 163

Working with References 166

Debugging 166

Copying 169

Slices 172

Summary 173

CHAPTER 7: SUBROUTINES 175

Subroutine Syntax 176

Argument Handling 177

Multiple Arguments 178

Named Arguments 179

Aliasing 181

State Variables (Pre- and Post-5.10) 181

Passing a List, Hash, or Hashref? 184

Returning Data 186

Returning True/False 186

Returning Single and Multiple Values 188

wantarray 189

FAIL! 190

“Wake Up! Time to Die!” 191

carp and croak 192

eval 192

evalGotchas 194

Try::Tiny 195

Subroutine References 196

Existing Subroutines 196

Anonymous Subroutines 197

Closures 197

Prototypes 200

Argument Coercion 200

More Prototype Tricks 202

Mimicking Builtins 204

Forward Declarations 206

Prototype Summary 207

Recursion 209

Basic Recursion 209

Divide and Conquer 210

Memoization 211

Things to Watch For 215

Argument Aliasing 215

Scope Issues 216

Doing Too Much 216

Too Many Arguments 217

Summary 217

CHAPTER 8: REGULAR EXPRESSIONS 219

Basic Matching 220

Quantifiers 221

Escape Sequences 223

Extracting Data 226

Modifiers and Anchors 228

Character Classes 231

Grouping 232

Advanced Matching 235

Substitutions 235

Lookahead/Lookbehind Anchors 236

Named Subexpressions (5.10) 238

Common Regular Expression Issues 241

Regexp::Common 241

E-mail Addresses 242

HTML 242

Composing Regular Expressions 243

Summary 245

CHAPTER 9: FILES AND DIRECTORIES 249

Basic File Handling 250

Opening and Reading a File 250

File Test Operators 258

The Diamond Operator 260

Temporary Files 260

DATA as a File 261

binmode 262

Directories 265

Reading Directories 265

Globbing 265

Unicode 266

What Is Unicode? 267

Two Simple Rules 267

Lots of Complicated Rules 271

Useful Modules 276

File::Find 276

File::Path 278

File::Find::Rule 279

Summary 284

CHAPTER 10: SORT, MAP, AND GREP 287

Basic Sorting 288

Sorting Alphabetically 288

Sorting Numerically 289

Reverse Sorting 290

Complex Sort Conditions 290

Writing a sort Subroutine 292

Sorting and Unicode Fun! 293

map and grep 297

Using grep 298

Using map 303

Aliasing Issues 305

Trying to Do Too Much 306

Trying to Be Clever 307

Putting It All Together 308

Schwartzian Transform (aka decorate, sort, undecorate) 308

Guttman-Rosler Transform 310

Summary 311

CHAPTER 11: PACKAGES AND MODULES 315

Namespaces and Packages 316

use Versus require 321

Package Variables 323

Version Numbers 326

Subroutines in Other Packages 327

Exporting 327

Naming Conventions 330

BEGIN, UNITCHECK, CHECK, INIT, and END 335

BEGIN blocks 336

END Blocks 337

INIT, CHECK, and UNITCHECK Blocks 337

Plain Old Documentation (POD) 338

Documentation Structure 340

Headings 340

Paragraphs 341

Lists 341

Verbatim 342

Miscellaneous 342

Creating and Installing Modules 344

Creating a Simple Module 344

Makefile.PL or Module::Build? 349

Summary 349

CHAPTER 12: OBJECT ORIENTED PERL 353

What Are Objects? The Ævar the Personal Shopper 354

Three Rules of Perl OO 355

Class Is a Package 355

An Object Is a Reference That Knows Its Class 356

A Method Is a Subroutine 358

Objects – Another View 371

Using TV::Episode 371

Subclassing 374

Using TV::Episode::Broadcast 375

Class Versus Instance Data 379

A Brief Recap 381

Overloading Objects 381

Using UNIVERSAL 385

Understanding Private Methods 387

Gotchas 393

Unnecessary Methods 393

“Reaching Inside” 394

Multiple Inheritance 394

Summary 397

CHAPTER 13: MOOSE 399

Understanding Basic Moose Syntax 400

Using Attributes 402

Using Constructors 405

Understanding Inheritance 408

Taking Care of Your Moose 409

Advanced Moose Syntax 413

Using Type Constraints 414

Using Method Modifiers 417

Understanding and Using Roles 420

Exploring MooseX 425

Rewriting Television::Episode 428

Moose Best Practices 433

Use namespace::autoclean and Make Your Class Immutable 434

Never Override new() 434

Always Call Your Parent BUILDARGS Method 434

Provide Defaults if an Attribute is Not Required 434

Default to Read-Only 434

Put Your Custom Types in One Module and Give Them a Namespace 435

Don’t Use Multiple Inheritance 435

Always Consume All Your Roles at Once 435

Summary 436

CHAPTER 14: TESTING 439

Basic Tests 440

Using Test::More 440

Writing Your Tests 442

Understanding the prove Utility 443

Understanding Test::More Test Functions 444

Using ok 445

Using is 445

Using like 448

Using is_deeply 449

Using SKIP 450

Using TODO 450

Using eval {} 451

Using use_ok and require_ok 452

Working with Miscellaneous Test Functions 453

Using Other Testing Modules 457

Using Test::Diff erences 457

Using Test::Exception 459

Using Test::Warn 460

Using Test::Most 460

Understanding xUnit Style Using Testing 461

Using Test::Class 461

A Basic Test Class 463

Extending a Test Class 467

Using Test Control Methods 471

Calling Parent Test Control Methods 473

Summary 477

CHAPTER 15: THE INTERWEBS 481

A Brief Introduction to HTTP 482

Plack 484

Hello, World! 484

Handling Parameters 490

Templates 492

Handling POST Requests 496

Sessions 500

Web Clients 511

Extracting Links from Web Pages 512

Extracting Comments from Web Pages 514

Filling Out Forms Programmatically 515

Summary 520

CHAPTER 16: DATABASES 523

Using the DBI 524

Connecting to a Database 524

Using SQLite 527

Using DBD::SQLite 527

Selecting Basic Data 533

Using SELECT Statements 533

Using Bind Parameters 536

Inserting and Updating Data 539

Creating Transactions 540

Handling Errors 541

Summary 542

CHAPTER 17: PLAYS WELL WITH OTHERS 545

The Command Line 546

Reading User Input 546

Handling Command-Line Arguments 548

perlrun 551

Other Programs 556

Running an External Program 556

Reading Another Program’s Output 559

Writing to Another Program’s Input 560

STDERR 562

Summary 565

CHAPTER 18: COMMON TASKS 567

Using CSV Data 568

Reading CSV Data 569

Writing CSV Data 570

Understanding Basic XML 571

Reading CSV Data 572

Writing CSV Data 576

Handling Dates 580

Using the DateTime Module 580

Using Date::Tiny and DateTime::Tiny 581

Understanding Your Program 587

Using the Debugger 587

Profiling 594

Perl::Critic 604

Summary 608

CHAPTER 19: THE NEXT STEPS 611

What Next? 612

What This Book Covers 612

What This Book Leaves Out 613

Understanding Object-Relational Mappers 613

Understanding DBIx::Class 614

Understanding Basic DBIx::Class Usage 614

Understanding the Pros and Cons of an ORM 618

Using DBIx::Class::Schema::Loader 624

Using the Template Toolkit 625

Why Use Templates? 625

An Introduction to Template Toolkit 626

Using Catalyst to Build Apps 634

The Beauty of MVC 635

Setting Up a Catalyst Application 635

Using Catalyst Views 641

Using Catalyst Models 643

Using Catalyst Controllers 646

CRUD: Create, Read, Update, and Delete 648

Summary 651

APPENDIX: ANSWERS TO EXERCISES 655

INDEX 695

Read More Show Less

Customer Reviews

Average Rating 5
( 1 )
Rating Distribution

5 Star

(1)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Posted December 10, 2012

    I bought this book more for review purposes, to get my skills in

    I bought this book more for review purposes, to get my skills in Perl back to what they should be, so that I could
    take them further.  I was pleasantly surprised to find that the author covered more detail than expected when he
    wrote this book.  His examples and the way he explains things makes understanding each topic all that much
    easier.  I am still reading the book, but I have learned more little obscure things that other Perl books designed
    for beginners just don't cover.
    The author has done a fantastic job of giving you a very solid grounding in the Perl language so that you can
    take the knowledge he has shared and go further.  His coverage of modern Perl topics, as well as great in-depth
     coverage of "must-learn" areas, makes this the new must have book in everyone's Perl bookshelf.  If you have
    no other book in your library, you need to have this one.  Without a doubt, this is the new bible for the Perl
    language.

    1 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)