Perl tutorial
Offered By: Independent
Course Description
Overview
The Perl Maven tutorial will teach you the basics of the Perl programming language. You'll be able to write simple scripts, analyze log files and read and write CSV files. Just to name a few common tasks.
You'll learn how to use CPAN and several specific CPAN modules.
It will be a good foundation for you to build on.
If you are interested in getting updated when new parts are published, please subscribe to the newsletter.
There is also an e-book version of the material available for purchase. In addition to the tutorial, the eBook also includes some material that is only available pro subscribers.
Syllabus
Introduction
- Install Perl, print Hello World, Safety net (use strict, use warnings)
- #!/usr/bin/perl - the hash-bang line
- Editors, IDEs, development environment for Perl
- Getting Help
- Perl on the command line
- Core Perl documentation, CPAN module documentation
- POD - Plain Old Documentation
- Debugging Perl scripts
Scalars
- Common warnings and error messages
- Prompt, read from STDIN, read from the keyboard
- Automatic string to number conversion
- Conditional statements: if
- Boolean (true and false) values in Perl
- Numerical operators
- String operators
- undef, the initial value and the defined function
- Strings in Perl: quoted, interpolated and escaped
- Here documents
- Scalar variables
- Comparing scalars
- String functions: length, lc, uc, index, substr
- Number Guessing game (rand, int)
- Perl while loop
- Scope of variables in Perl
- Boolean Short circuit
Files
- exit
- Standard Output, Standard Error and command line redirection
- warn
- die
- Writing to files
- Appending to files
- Open and read from files using Perl
- Don't open files in the old way
- Binary mode - reading and writing binary files
- eof, end of file in Perl
- tell
- seek
- truncate
- Slurp mode
Lists and Arrays
- Perl foreach loop
- The for loop in Perl
- Lists in Perl
- Using Modules
- Arrays in Perl
- Process command line parameters @ARGV
- Process command line parameters using Getopt::Long
- Advanced usage of Getopt::Long for accepting command line arguments
- split
- How to read and process a CSV file? (split, Text::CSV_XS)
- join
- The year of 19100 (time, localtime, gmtime) and introducing context
- Context sensitivity in Perl
- Reading from a file in scalar and list context
- STDIN in scalar and list context
- Sorting arrays in Perl
- Sorting mixed strings
- Unique values in an array in Perl
- Manipulating Perl arrays: shift, unshift, push, pop
- Stack
- Queue
- reverse
- The ternary operator
- Loop controls: next and last
- min, max, sum using List::Util
- qw - quote word
Subroutines
- Subroutines and Functions in Perl
- Passing multiple parameters to a function
- Variable number of parameters
- Returning a list, returning an array
- Recursive subroutines
Hashes
- Perl Hashes (dictionary, associative array, look-up table)
- Creating hash from an array
- Perl hash in scalar and list context
- exists hash element
- delete hash elements
- Sorting a hash
- Count word frequency in a text file
Regular Expressions
- Introduction to Regular Expressions in Perl
- Regex: character classes
- Regex: special character classes
- Regex: quantifiers
- Regex: Greedy and non-greedy match
- Regex: Grouping and capturing
- Regex: Anchors
- Regex options and modifiers
- Substitutions (search and replace)
- trim - remove leading and trailing spaces
- Perl 5 Regex Cheat sheet
Shell related functionality
- Perl -X operators
- Perl pipes
- Unix commands: chmod, chown, cd, mkdir, rmdir, ln, ls
- Unix commands: pwd - current working directory
- Running external programs using system
- Capturning the output of an external program using qx or backticks
- Capturing output asynchronously
- Capturing both STDOUT and STDERR
- Unix commands: rm, mv, cp: How to remove, copy or rename a file with Perl
- Windows/DOS commands: del, ren, dir
- File globbing (Wildcards)
- Directory handles
- Traversing directory tree manually with recursion
- Traversing directory tree manually using a queue and using find.
CPAN
- Download and install Perl (Strawberry Perl or manual compilation)
- Download and install Perl using Perlbrew
- Locating and evaluating CPAN modules
- Downloading and installing Perl Modules from CPAN
- How to change @INC to find Perl modules in non-standard locations?
- How to change @INC to a relative directory
- local::lib
Examples for using Perl
- How to replace a string in a file with Perl? (slurp)
- Reading Excel files using Perl
- Creating Excel files using Perl
- Sending e-mail using Perl
- CGI scripts with Perl
- Parsing XML files
- Reading and writing JSON files
- Database access using Perl (DBI, DBD::SQLite, MySQL, PostgreSQL, ODBC)
- Accessing LDAP using Perl
Common warnings and error messages
- Global symbol requires explicit package name ...
- .. also explained in Variable declaration in Perl
- Use of uninitialized value
- Bareword not allowed while "strict subs" in use
- Name "main::x" used only once: possible typo at ...
- Unknown warnings category
- Can't use string (...) as a HASH ref while "strict refs" in use at ... ...
- ... explained in Symbolic references in Perl
- Can't locate ... in @INC
- Scalar found where operator expected
- "my" variable masks earlier declaration in same scope
- Can't call method ... on unblessed reference
- Argument ... isn't numeric in numeric ...
- Can't locate object method "..." via package "1" (perhaps you forgot to load "1"?)
- Odd number of elements in hash assignment
- Possible attempt to separate words with commas
- Undefined subroutine ... called
- Useless use of hash element in void context
- Useless use of private variable in void context
- readline() on closed filehandle
- Possible precedence issue with control flow operator
- Scalar value better written as ...
- substr outside of string at ...
- Have exceeded the maximum number of attempts (1000) to open temp file/dir
- Deep recursion on subroutine
- Use of implicit split to @_ is deprecated ...
Extra articles
- Multi dimensional arrays
- Multi dimensional hashes
- Minimal requirement to build a sane CPAN package
- Statement modifiers: reversed if statements
- autovivification
- Formatted printing in Perl using printf and sprintf
From other books
- Splice to slice and dice arrays in Perl
- How to improve your Perl code
Related Courses
The Definitive Ethical Hacking Course - Learn From ScratchUdemy Sıfırdan C++ Eğitimi
Udemy Polyglot Web Development
LinkedIn Learning Learn Perl 5 By Doing It
Udemy Curso de programação com Perl para Bioinformática
Udemy