Perl%20Tutorial.!Picking%20Up%20Perl
Upcoming SlideShare
Loading in...5
×
 

Perl%20Tutorial.!Picking%20Up%20Perl

on

  • 1,173 views

 

Statistics

Views

Total Views
1,173
Views on SlideShare
1,173
Embed Views
0

Actions

Likes
0
Downloads
16
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Perl%20Tutorial.!Picking%20Up%20Perl Perl%20Tutorial.!Picking%20Up%20Perl Document Transcript

  • NodeTop, Next:Preface, Previous:(dir), Up:(dir)  Preface:  Overview of Perl:  Scalars:  Arrays:  Control Structures:  Associative Arrays (Hashes):  Advanced Control Structures:  Input and Output:  Regular Expressions:  Subroutines:  File Input and Output:  Directories:  File System Manipulation:  Formats:  Using Modules:  Going Further:  General Index:  --- The Detailed Node Listing ---  Preface  Purpose of this Book:  Contributors:  Obtaining the Most Recent Version:  Audience: Who should read this book?  Material Covered: What does this book cover?  Conventions Used in this Book: How do I read this book?  Where to Find Perl Information: Where can I get more information?  Overview of Perl  Perl Background: History and Philosophy of Perl.  A First Perl Program: A Simple Example.  Running Perl on Your System: How to run Perl.  Expression Evaluation: How Perl expressions are evaluated.  Overview Exercises: Exercises to learn from.  Perl Background  The History of Perl: Historical information on Perl.  Perl as a Natural Language: How Perl can be considered a ``natural language''.  The Slogans: Some common sayings that might help a new programmer understand Perl.  Running Perl on Your System  Perl on a Unix-like System: Using Perl in a Unix-like environment.  Perl on a Microsoft Windows System: Using Perl on a Microsoft system.  The Online Perl Documentation: Finding the documentation that comes with Perl. Page 1
  •  Scalars  Strings: Using strings of characters in Perl.  Numbers: Using numerical values in Perl.  Scalar Variables: Storing scalar data into variables.  Operators: Operators that work on scalar data.  Output of Scalar Data:  Special Variables: Special scalar variables to be aware of.  Summary of Scalar Operators:  Scalar Exercises: Exercises to learn from.  Strings  Single-quoted Strings:  A Digression---The print Function:  Double-quoted Strings:  Here Document Strings:  Single-quoted Strings  Special Characters in Single-quoted Strings:  Newlines in Single-quoted Strings:  Examples of Illegal Single-quoted Strings:  Double-quoted Strings  Interpolation in Double-quoted Strings:  Examples of Interpolation:  Examples of Interpolation (ASCII Octal Values):  Examples of Interpolation (ASCII Hex Values):  Characters Requiring Special Consideration:  Numbers  Numeric Literals: Numeric values in Perl  Numeric Literals  Printing Numeric Literals: Using print with numeric literals  Scalar Variables  Scalar Interpolation: Expanding scalar variables in double-quoted strings  Undefined Variables: Before a Variable has a value, It is undefined  Operators  Numerical Operators: Operators for numeric scalars  Comparison Operators: Operators to compare scalars with each other  Auto-Increment and Decrement:  String Operators: Operators for string scalars  Arrays  The Semantics of Arrays:  List Literals:  Array Variables: Page 2
  •  Manipulating Arrays and Lists:  Array Exercises:  Array Variables  Using Array Variables:  Associated Scalars:  Manipulating Arrays and Lists  It Slices!:  Functions:  The Context (List vs. Scalar):  Array Interpolation:  Functions  Arrays as Stacks:  Arrays as Queues:  Control Structures  Blocks:  A Digression---Truth Values:  The if/unless Structures:  The while/until Structures:  The do while/until Structures:  The for Structure:  The foreach Structure:  Control Structure Exercises:  Associative Arrays (Hashes)  What Is It?:  Hash Variables:  Hash Literals:  Hash Functions:  Slices:  Context Considerations:  Hash Exercises:  Functions  Keys and Values:  Each:  Advanced Control Structures  last and next:  redo:  Labeled Blocks:  Expression Modifiers and Boolean Structures:  Advanced Control Structure Exercises:  Input and Output Page 3
  •  STDOUT:  STDIN:  STDERR:  Reading Input:  Printing and Output:  Special Variables for I/O:  I/O Exercises:  Regular Expressions  The Theory Behind It All:  The Simple:  Pattern Matching:  Regular Expression Shortcuts:  Regular Expression Exercises:  The Simple  Simple Characters:  The * Special Character:  The . Character:  The | Character:  Grouping with ()s:  The Anchor Characters:  Subroutines  Defining Subroutines:  Returning Values:  Using Arguments:  Dynamic vs. Lexical Scoping:  Subroutine Exercises:  File Input and Output  Filehandles:  Open and Close:  Easy Input and Output with Filehandles:  File Tests:  The stat Function:  File I/O Exercises:  Directories  Moving Around:  Globbing:  Directory Handles:  Reading Directory Information:  Directory Exercises:  File System Manipulation  Renaming and Removing:  Creation: Page 4
  •  Permissions:  Timestamps:  File System Exercises:  Formats  Format Exercises:  Using Modules  The use Pragma:  Importing Functions:  Controlling What Is Imported:  A Module Example (CGI.pm):  Useful Default Modules:  Downloading and Installing CPAN Modules: NodePreface, Next:Overview of Perl, Previous:Top, Up:Top Preface  Purpose of this Book:  Contributors:  Obtaining the Most Recent Version:  Audience: Who should read this book?  Material Covered: What does this book cover?  Conventions Used in this Book: How do I read this book?  Where to Find Perl Information: Where can I get more information? NodePurpose of this Book, Next:Contributors, Previous:Preface, Up:Preface Purpose of this Book This book has been created for a number of reasons. The primary reason is to provide a freely redistributable tutorial for the Perl language. In writing a freely redistributable tutorial, it is our hope that the largest number of people can have access to it and share it. We are a community of Perl programmers. We have discovered ways to save time and money by writing Perl programs that make our jobs and lives easier. Surely, Perl is not a panacea, but it has certainly made our lives a little bit easier. It is our hope that you can use Perl to make your jobs and lives easier. NodeContributors, Next:Obtaining the Most Recent Version, Previous:Purpose of this Book, Up: Preface Contributors Bradley M. Kuhn (bkuhn@ebb.org) served as "pumpking" (aka editor) for the first edition of this book. Page 5
  • In addition, he wrote most of the chapters for the first edition. Greg Bacon (gbacon@cs.uah.edu) was the first to provide grammar and error correcting patches to the early, pre-release editions. NodeObtaining the Most Recent Version, Next:Audience, Previous:Contributors, Up:Preface Obtaining the Most Recent Version This book is still under development. The most recent version can be obtained at http://www.ebb.org/PickingUpPerl. NodeAudience, Next:Material Covered, Previous:Obtaining the Most Recent Version, Up:Preface Audience This book is designed for readers who are already competent programmers. Perl is a wonderful programming language, but is really not the best choice for a first programming language. Since that is the case, we have chosen to write this book for the audience of those who are already familiar with general programming concepts, but are completely new to Perl. This book does not that assume any prior knowledge of Perl. However, a reader familiar with standard computer science concepts such as abstraction, stacks, queues, and hash tables will definitely find her way through this book with ease. In other words, anyone with a knowledge equivalent to a first-year of college computer science courses should find this book very basic, and those of less experience may find it much more challenging. NodeMaterial Covered, Next:Conventions Used in this Book, Previous:Audience, Up:Preface Material Covered The material covered in this book is designed to prepare the reader to enter the world of Perl programming. This book covers the basic data and control structures of Perl, as well as the philosophies behind Perl programming. The native search patterns used in Perl, called regular expressions, are introduced and discussed. The basics of input and output and file system manipulation in Perl are explained. Finally, a "real world" example of working with and using modules that other programmers have written is given. NodeConventions Used in this Book, Next:Where to Find Perl Information, Previous:Material Covered, Up:Preface Conventions Used in this Book In this text, a variety of conventions will be used to explain the material. Certain typographical and display elements will be used for didactic purposes. Page 6
  • Any Perl code that is included directly in flowing text appears like this: code. Any operating system commands or files that are discussed directly in the flowing text appear like this: file. When a particularly term of importance is first introduced, they appear in emphasized text, like this: an important term. When Perl code examples or operating system commands need to be separated away from the flowing text for emphasis, or because the code is long, it appears like this: my $x = "foo"; # This is a Perl assignment p Page 7