Mastering Perl: A Beginner's Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Mastering Perl helps readers to learn the Perl programming language with real-world examples. High-level, interpreted, and multipurpose, Perl’s roots are in text manipulation. It is used for UI development in system administration, networking, and other fields, borrowing heavily from C and Shell scripts.

Among programmers, Perl is also known as "Pathologically Eclectic Rubbish Lister" or "Practically Everything Really Likable." Since Perl’s inception, it has mostly been used for text processing, namely the extraction of data from text files and its subsequent transformation into other formats.

In addition to being interoperable with HTML, XML, and other markup languages, Perl provides cross-platform compatibility. It is Open Source, meaning it is free to use and licensed under both the Artistic and GNU General Public Licenses (GPL).

With Mastering Perl, learning Perl becomes a charm and will help readers undoubtedly advance their careers.

Author(s): Sufyan bin Uzayr
Series: Mastering Computer Science
Publisher: CRC Press
Year: 2023

Language: English
Pages: 311
City: Boca Raton

Cover
Half Title
Series Page
Title Page
Copyright Page
Dedication
Contents
About the Editor
Acknowledgments
Zeba Academy – Mastering Computer Science
CHAPTER 1: Introduction
EVOLUTION OF PERL
WHY PERL?
PERL FEATURES
PERL APPLICATION
PERL IMPLEMENTATION
PROGRAMMING IN PERL
Comments
Perl’s Benefits
Perl’s Disadvantages
Applications
PERL INSTALLATION AND CONFIGURATION ON WINDOWS, LINUX, AND MACOS
PERL DOWNLOAD AND INSTALLATION
HELLO WORLD PROGRAM
HOW TO EXECUTE A PERL PROGRAM
Windows
Unix/Linux
A PERL PROGRAM’S BASIC SYNTAX
Variables
Expressions
Comments
Statements
Block
Functions or Subroutines
Loops
Whitespaces and Indentation
Keywords
DATA TYPES
Scalars
Arrays
Hashes
NOTE
CHAPTER 2: Fundamentals of Perl
PERL CODE WRITING METHODS
Interactive Mode
Script Mode
One-Liner Mode
BOOLEAN VALUES IN PERL
OPERATORS
Arithmetic Operators
Addition
Subtraction
Multiplication
Division
Modulus
Exponent Operator
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Ternary Operator
VARIABLES IN PERL
Naming of a Variable
Declaration of a Variable
Modification of a Variable
Variable Interpolation
VARIABLES AND ITS TYPES
Creating Variables
Scalar Variables
Array Variables
Hash Variables
Variable Context
SCOPE OF VARIABLES
The Scope of Global Variables
Lexical Variables’ Scope (Private Variables)
Package Variables
MODULES IN PERL
Making a Perl Module
Importing and Using a Perl Module
Utilizing Module Variables
Making Use of predefined Modules
PERL PACKAGES
Perl Module Declaration
Making Use of a Perl Module
Using a Different Directory to Access a Package
Utilizing Module Variables
Begin and End Block
NUMBER AND ITS TYPES IN PERL
DIRECTORIES WITH CRUD OPERATIONS IN PERL
Making a New Directory
Opening an Existing Directory
Read Directory in the Scalar and List Context
Modifying Directory Path
Directory Closing
Delete a Directory
NOTES
CHAPTER 3: Input and Output in Perl
PERL print() AND say() METHODS
print() Operator
say() Function
print OPERATOR
USE OF STDIN FOR INPUT
CHAPTER 4: Control Flow in Perl
DECISION-MAKING IN PERL
if Statement
if else Statement
Nested if Statement
if elsif else ladder Statement
unless Statement
unless else Statement
unless elsif Statement
LOOPS IN PERL
for Loop
foreach Loop
while Loop
Infinite While Loop
do...while loop
until Loop
Nested Loops
given-when STATEMENT
Nested given-when Statement
goto STATEMENT
next OPERATOR
redo OPERATOR
last IN LOOP
NOTES
CHAPTER 5: File Handling in Perl
INTRODUCTION OF FILE HANDLING
Using FileHandle To Read and Write to a File
Various File Handling Modes
Redirecting Output
FILE OPENING AND READING
Opening a File
Reading a File
FileHandle Operator
getc Function
read Function
Reading More than One Line at a Time
Exception Handling in Files
Throw an Exception
Give a Warning
WRITING TO A FILE
print() Function
Error Handling and Error Reporting
Throw an Exception (Using Die Function)
Give a Warning (Using Warn Function)
APPENDING TO A FILE
CSV FILE READING
Use of Split() for Data Extraction
Character Escaping a Comma
Installation of the TEXT::CSV
Fields with Newlines Embedded
FILE TEST OPERATORS
FILE LOCKING
flock()
flock() vs lockf()
SLURP MODULE
USEFUL FILE-HANDLING FUNCTIONS
CHAPTER 6: Regular Expressions in Perl
OPERATORS IN REGULAR EXPRESSION
REGEX CHARACTER CLASSES
SPECIAL CHARACTER CLASSES IN REGULAR EXPRESSIONS
QUANTIFIERS IN REGULAR EXPRESSION
Quantifier Table
BACKTRACKING IN REGULAR EXPRESSION
BACKTRACKING
“e” MODIFIER IN REGULAR EXPRESSION
The Substitution Operation Is Performed using a Subroutine
REGEX “ee” MODIFIER
When Doing Mathematical Calculations, Use the “ee” Modifier
pos() FUNCTION IN REGULAR EXPRESSION
To Match from a Specified Position, use \G Assertion
REGEX CHEAT SHEET
Character Classes
Anchors
Metacharacters
Quantifiers
Modifiers
White Space Modifiers
Quantifiers – Modifiers
Grouping and Capturing
SEARCHING IN A FILE USING REGEX
Regular Search
Using Word Boundary in the Regex Search
Use of Wildcards in the Regular Expression
CHAPTER 7: Object-Oriented Programming in Perl
CLASSES IN OOP
Object
Class
Data Member
Defining a Class
Creating a Class and Making Use of Objects
Creating a Class Instance
Creating an Object
OBJECTS IN OOPs
METHODS IN OOPs
Types of Methods in Perl
get-set Methods
CONSTRUCTORS AND DESTRUCTORS
Constructors
Passing Dynamic Attributes
Destructors
METHOD OVERRIDING IN OOPs
Why Do We Override Methods?
INHERITANCE IN OOPs
Base Class and Derived Class
Multilevel Inheritance
Implementing Inheritance in the Perl
POLYMORPHISM IN OOPs
ENCAPSULATION IN OOPs
NOTE
CHAPTER 8: Subroutines in Perl
SUBROUTINES OR FUNCTIONS
Determining Subroutines
Calling Subroutines
Passing Parameters to Subroutines
Passing Hashes to Subroutines
Passing Lists to Subroutines
Returning a Value from a Subroutine
Local and Global Variables in Subroutines
A Varying Number of Parameters in a Subroutine Call
FUNCTION SIGNATURE IN PERL
Defining Subroutines
Function Signature
Passing Parameters of a Type other than that Specified in the Signature
Difference in Number of Arguments
PASSING COMPLEX PARAMETERS TO A SUBROUTINE
MUTABLE AND IMMUTABLE PARAMETERS
Mutable Parameters
Immutable Parameters
Traits
MULTIPLE SUBROUTINES
Subroutine Definition
Use of the “multi” Keyword
return() FUNCTION
REFERENCES IN PERL
Making a Reference
Dereferencing
PASS BY REFERENCE
PERL RECURSION
APPRAISAL
BIBLIOGRAPHY
INDEX