The Snippets

These snippets are available for download by any legitimate user of the book, for the purpose of understanding the concepts of Perl. Any other use is strictly prohibited and is a copyright violation. All snippets are ©2020 J.P. Hurst

Return to Main Page

Available snippets:

0.1.py>Add first 10,000,000 Numbers in Python
1.1.1.py>Python's Indentation
1.6.1.py>Semi-Dynamic Typing
1.14.1.py>Braces are Worse
2.1.1.pl>Hello World in Perl
2.1.2.py>Hello World for Python2
2.1.3.py>Hello World for Python3
2.2.1.pl>First Use of a Variable
2.2.2.pl>Adding Numbers
2.2.3.pl>Interpolation
2.2.4.pl>Arrays
2.2.5.pl>More on Arrays
2.2.6.pl>An Array is a Collection of Scalars
2.2.2.1.pl>Arrays as Array Elements
2.3.1.pl>Loop
2.3.2.pl>Iterating
2.3.3.pl>Iterating with the Special Variable
2.4.1.pl>Multi-Statement Lines
2.4.2.pl>Indentation
2.6.1.pl>Typical For Loop
2.6.2.pl>More Ranges
2.7.1.pl>Hashes
2.7.2.pl>Printing a Hash
2.7.3.pl>Sorting Hashes
2.7.4.pl>Printing Hashes Usefully
2.8.1.1.pl>Index Keyword
2.8.2.1.pl>Sub-Strings
2.9.1.pl>Scope
2.9.2.py>Scope in Functions
2.9.3.pl>Scope in Perl Subroutunes
2.9.4.pl>Hiding Scope
2.9.5.pl>Types of Scope
2.10.1.pl>Strict and Warnings
2.10.2.pl>Use of Strict
2.10.3.pl>Use of Warnings
2.10.4.pl>Say
2.11.1.pl>Formatting
2.12.1.pl>Elsif
2.12.2.pl>Testing Truth
2.13.1.pl>Strings v Numbers
2.15.1.pl>Fibonacci
2.15.2.pl>Better Fibonacci
2.16.1.pl>Subroutines
2.16.2.pl>Return Values
2.16.2.1.pl>Arguments
2.16.2.2.pl>Arguments as a List
2.16.3.1.pl>Signatures
2.16.3.2.pl>More of Signatures
2.16.3.3.pl>Signatures and Arrays
2.16.4.1.pl>Anonymous Subroutines
2.16.5.1.pl>References to Subroutines
2.16.6.1.pl>Closures
2.16.7.1.py>Lambdas
2.16.7.2.pl>Incrementor
2.17.1.pl>RegEx
2.17.2.pl>Case in RegEx
2.17.1.1.pl>$MATCH
2.17.2.1.pl>Anchors
2.17.3.1.pl>Character Classes
2.17.5.1.pl>RegEx Modifiers
2.17.6.1.pl>More on RegEx
2.17.6.2.pl>Recognizing Days
2.17.8.1.pl>RegEx Substitutions
2.17.8.2.pl>Assignment Results
2.17.8.3.pl>More Complex RegEx
2.17.10.1.pl>RegEx for Assignment
2.17.11.1.pl>Phone Number Validation
2.17.12.1.pl>Global in RegEx
2.17.13.1.pl>Multi-Line RegEx
2.17.13.2.pl>RegEx with Multi-Lines
2.18.1.1.pl>HEREDOC
2.18.1.2.pl>Indented HEREDOCs
2.18.2.1.pl>Validate Date Subroutine
validateDate.pl>ValidateDate Module
2.18.2.2.pl>Using ValidateDate
2.19.1.pl>Importing a Subroutine
2.20.1.pl>File Access
2.22.1.pl>Constants
2.23.1.pl>Eval
2.24.1.pl>Flip-Flop
2.24.2.pl>Flip-Flop with Line Numbers
3.1.1.1.pl>Case Conversion
3.2.1.1.pl>Copying an Array
3.2.1.2.pl>More on Array Copy
3.2.1.3.py>Python's List Copy
3.2.2.1.pl>Grep
3.2.3.1.pl>Map
3.2.3.2.pl>Modify In-Place
3.2.4.1.pl>Splice
3.2.5.1.pl>Count Words
textToCount.dat>Words to Count
countWords.out>Count Results
3.5.1.pl>Line Count
3.5.1.1.pl>Double Diamond
3.6.1.pl>Glob
3.7.2.1.pl>Testing Hashes
3.8.1.pl>Day Test
3.8.1.1.pl>RegEx Phone Number
3.9.1.pl>References
3.9.2.pl>De-Referencing
3.9.3.pl>Reference to an Array
3.9.4.pl>Test Range
3.9.5.pl>Argument Checking
3.10.1.pl>More Array Referencing
3.10.2.pl>Referencing Subroutines
3.10.3.pl>Anonymous Hash
3.11.1.pl>Wantarray
3.12.1.pl>Trapping Signals
3.13.1.pl>More on Signals
3.14.1.pl>Backticks
3.14.2.pl>Open a Pipe
3.14.3.pl>Open SendMail
3.15.1.pl>ENV
4.1.1.pl>Lexical Blocks
4.1.2.pl>NameSpaces
4.2.1.pl>Code for Module
AtestClass.pm>A Test Module
4.2.2.pl>Getter/Setter
4.2.3.pl>Objects
4.2.4.pl>Using an Object
4.3.1.pl>Using a Module
4.3.2.1.pl>Destructor
AtestClass2.pm>A Module with a Destructor
4.3.2.2.pl>More Scoping
4.3.6.1.pl>Inheritance
4.4.1.1.pm>Our
Module1.pm>A Module
4.4.1.2.pl>Accessing Class Data
4.4.2.1.pl>Alarms
4.4.4.1.pl>State
4.4.4.2.pl>Pseudo Closure
4.4.5.1.pl>Still More on Scope
4.5.1.pl>Access Class Functions
4.5.2.pm>Export_OK
FunctionClass.pm>Function Class
5.3.1.pl>Windows v *nix
5.4.1.pl>Comma
5.4.2.pl>Using Matches
5.5.1.pl>Sort
5.5.2.pl>Case Insensitive Sort
5.5.3.pl>More on Sort
5.5.4.pl>Reverse Sort
5.5.5.pl>Text Sort
5.5.6.pl>Numeric Sort
5.6.1.pl>Arguments
5.7.1.pl>Tie
5.7.2.pl>AnyDBM_File
5.7.1.1.pl>Push With Tie
5.7.3.1.pm>A Module
AutoInc.pm>AutoInc
5.7.3.2.pl>Include Path
5.8.1.pl>JSON
5.10.1.pl>Flock
5.10.2.pl>Seek
5.10.1.1.pl>Flush
5.11.1.pl>Hex and Chr
5.14.4.1.pl>Embed
5.15.1.pl>BEGIN
5.15.1.1.pl>AUTILOAD
5.16.1.pl>__DATA__
5.19.1.1.pl>More on Do
5.19.1.2.pl>Alternate Do
5.19.1.3.pl>Do Like a Loop
5.19.2.1.pl>Unless
5.19.3.1.pl>Instead of Unless
5.19.4.1.pl>If as a Post Condition
5.19.4.2.pl>Exit the Theatre
5.19.5.1.pl>SmartMatch
7.2.1.1.pl>For Debug
7.5.1.pl>Caller
7.7.1.pl>Taint
8.3.1.1.py>Python's Weird Behaviour
x1428.py>Set 1428
8.3.2.1.py>Confusing Dictionaries
8.3.3.1.py>Simple Class
8.3.3.2.py>Sequence Should Not Change Results
8.3.4.1.py>What Gets Made
8.3.5.1.py>Making a Generator
8.9.1.py>Slow Python
8.9.2.pl>Perl Speed Test
8.9.3.pl>Better Perl Speed Test
8.9.1.1.py>Python Gets Slower
8.19.1.py>Confusion with Braces
8.19.2.py>Python's Strange Behaviour
8.22.1.py>RegEx in Python
8.25.1.pl>Precedence in Perl
8.25.2.py>Precedence in Python
9.2.1.pl>Threads
9.5.1.py>Threading
9.5.2.pl>Threaded
B.1.py>Pyton's Slow RegEx
B.2.pl>Perl on RegEx
B.png.txt>The Image
rogues.zip>The Files to Rename
E.1.pl>Rename a Group of Files
Perl Image