Impatient Perl

Impatient Perl

Impatient Perl version: 9 September 2010 Copyright 2004-2010 Greg London Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Cover Art (Front and Back) on the paperback version of Impatient Perl is excluded from this license. Cover Art is Copyright Greg London 2004, All Rights Reserved. For latest version of this work go to: http://www.greglondon.com 1 Table of Contents 1 The Impatient Introduction to Perl..........................................................................................................7 1.1 The history of perl in 100 words or less..........................................................................................7 1.2 Basic Formatting for this Document...............................................................................................7 1.3 Do You Have Perl Installed.............................................................................................................8 1.4 Your First Perl Script, EVER..........................................................................................................9 1.5 Default Script Header......................................................................................................................9 1.6 Free Reference Material................................................................................................................10 1.7 Cheap Reference Material.............................................................................................................10 1.8 Acronyms and Terms....................................................................................................................10 2 Storage..................................................................................................................................................11 2.1 Scalars...........................................................................................................................................11 2.1.1 Scalar Strings.........................................................................................................................12 2.1.1.1 String Literals.................................................................................................................12 2.1.1.2 Single quotes versus Double quotes..............................................................................13 2.1.1.3 chomp.............................................................................................................................13 2.1.1.4 concatenation.................................................................................................................13 2.1.1.5 repetition........................................................................................................................13 2.1.1.6 length..............................................................................................................................13 2.1.1.7 substr..............................................................................................................................13 2.1.1.8 split.................................................................................................................................14 2.1.1.9 join.................................................................................................................................14 2.1.1.10 qw.................................................................................................................................15 2.1.1.11 Multi-Line Strings, HERE Documents........................................................................15 2.1.2 Scalar Numbers......................................................................................................................16 2.1.2.1 Numeric Literals............................................................................................................16 2.1.2.2 Numeric Functions.........................................................................................................16 2.1.2.3 abs..................................................................................................................................16 2.1.2.4 int...................................................................................................................................16 2.1.2.5 trigonometry (sin,cos)....................................................................................................17 2.1.2.6 exponentiation................................................................................................................17 2.1.2.7 sqrt..................................................................................................................................17 2.1.2.8 natural logarithms(exp,log)............................................................................................18 2.1.2.9 random numbers (rand, srand).......................................................................................18 2.1.3 Converting Between Strings and Numbers.......................................................................19 2.1.3.1 Stringify.........................................................................................................................19 2.1.3.1.1 sprintf.....................................................................................................................19 2.1.3.2 Numify...........................................................................................................................20 2.1.3.2.1 oct...........................................................................................................................21 2.1.3.2.2 hex..........................................................................................................................21 2.1.3.2.3 Base Conversion Overview....................................................................................21 2.1.4 Undefined and Uninitialized Scalars.....................................................................................22 2.1.5 Booleans................................................................................................................................23 2 2.1.5.1 FALSE...........................................................................................................................24 2.1.5.2 TRUE.............................................................................................................................24 2.1.5.3 Comparators...................................................................................................................25 2.1.5.4 Logical Operators...........................................................................................................26 2.1.5.4.1 Default Values........................................................................................................27 2.1.5.4.2 Flow Control..........................................................................................................27 2.1.5.4.3 Precedence..............................................................................................................27 2.1.5.4.4 Assignment Precedence..........................................................................................27 2.1.5.4.5 Flow Control Precedence.......................................................................................28 2.1.5.4.6 Conditional Operator..............................................................................................28 2.1.6 References..............................................................................................................................29 2.1.7 Filehandles.............................................................................................................................31 2.1.8 Scalar Review........................................................................................................................32 2.2 Arrays............................................................................................................................................32 2.2.1 scalar (@array)......................................................................................................................33 2.2.2 push(@array, LIST)...............................................................................................................34 2.2.3 pop(@array)...........................................................................................................................34 2.2.4 shift(@array)..........................................................................................................................35 2.2.5 unshift( @array, LIST)..........................................................................................................35 2.2.6 foreach (@array)....................................................................................................................36 2.2.7 sort(@array)...........................................................................................................................37 2.2.8 reverse(@array).....................................................................................................................38 2.2.9 splice(@array).......................................................................................................................39

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    151 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us