Perl for System Administrators

Perl Scripting & Advanced Features

TTPS2647

Introductory

4 Days

Course Overview

Perl for System Administrators is an introductory-level hands-on Perl training course that course leads the student from the basics of writing and running Perl scripts to more advanced features such as file operations, report writing, the use of regular expressions, working with binary data files, and using the extensive functionality of the standard Perl library. Once these skills are mastered, this intensive course moves into practical tools for automating Linux/Unix system administration. Students will learn how to convert existing bash scripts to Perl, and create new scripts that will safely and securely automate system administration tasks.

Course Topics Covered: Students will learn and explore:

  • Variables and constants
  • Conditions and iterations
  • Arrays and hashes
  • Working with Files
  • Formatting output
  • Executing programs
  • References and data structures
  • Working with files and directories
  • Regular Expressions
  • Subroutines
  • Monitoring processes
  • Shortcuts and Defaults
  • Using the Standard Library

Course Objectives

Throughout the course students will be led through a series of progressively advanced topics, where each topic consists of lecture, group discussion, comprehensive hands-on lab exercises, and lab review. This course is “skills-centric”, designed to train attendees in core Perl scripting tasks appropriate for systems administrators.   

Working within in an engaging, hands-on learning environment, guided by our expert practitioner, students will learn to:

  • Create a working script that gets input from the command line, the keyboard, or a file
  • Use arrays to store and process data from files
  • Create formatted reports
  • Launch external programs
  • Interface with bash scripts
  • Understand and use regular expressions
  • Use the appropriate types of variables and data structures
  • Refactor duplicate code into subroutines and modules
  • Know what is available in the standard library

Course Prerequisites

This course is appropriate for anyone who wants to automate and simplify common system administration tasks with Perl. 

Students should already have a working, user-level knowledge of a Unix-like operating system (Linux, Solaris, Mac OS, e.g.). While not mandatory, basic skills with at least one other programming language are desirable.

Course Agenda

Session: Getting Started

  • What is Perl?
  • Structure of a Perl program
  • Running a Perl script
  • Checking syntax and warnings
  • Execution of scripts under Unix and Windows

Session: Basic Data and I/O

  • Numeric and Text literals
  • Math operators and expressions
  • Scalar variables
  • Default values
  • Writing to standard output
  • Command line arguments
  • Reading from the standard input

Session: Logic and Loops

  • About flow control
  • The if statement and Boolean values
  • Using unless and elsif
  • Statement modifiers
  • warn() and die()
  • The conditional construct
  • Using while loop and its variants
  • Using the for loop
  • Exiting from loops

Session: Lists and Arrays

  • The list data type
  • Accessing array elements
  • Creating arrays
  • List interpolation
  • Arrays and memory
  • Counting elements
  • Iterating through an array
  • List evaluation
  • Slices and ranges

Session: Reading and writing text files

  • File I/O Overview
  • Opening a file
  • Reading text files
  • Writing to a text file
  • Arrays and file I/O
  • Using the <> operator

Session: List functions

  • Growing and shrinking arrays
  • The split() function
  • Splitting on whitespace
  • Assigning to literal lists
  • The join() function
  • The sort() function
  • Alternate sort keys
  • Reversing an array

Session: Formatting output

  • Report formatting overview
  • Defining report formats
  • The write() function

Session: Hashes

  • Hash overview
  • Creating hashes
  • Hash attributes
  • Traversing a hash
  • Testing for existence of elements
  • Deleting hash elements

Session: References and data structures

  • What is a reference?
  • The two ways to create references
  • References to existing data
  • References to anonymous data
  • Dereferencing scalar, array, and hash references
  • Dereferencing elements of arrays and hashes
  • Multidimensional arrays and other data structures
  • Sorting data structures

Session: Text and Regular Expressions

  • String length
  • String functions and operators
  • Quoting in Perl
  • Regular expressions
  • Advanced pattern matching and substitution

Session: Subroutines and variable scope

  • Understanding packages
  • Package and Lexical variables
  • Localizing builtin variables
  • Declaring  and calling subroutines
  • Calling subroutines
  • Passing parameters and returning values

Session: Managing files and directories

  • File attributes
  • Reading a directory
  • Using File::Find
  • Permissions
  • Copying and moving files
  • Renaming and deleting files and directories
  • File test operators

Session: Sys Admin Part 1

  • Environment variables
  • Running external programs
  • User identification
  • Trapping signals
  • Backtick operator
  • Time of day

Session: Shortcuts and defaults

  • Understanding $_
  • shift() with no array specified
  • Text file processing
  • Using grep() and Using map()
  • Command-line options for  file processing

Session: Using Modules

  • Perl modules
  • Use vs. require
  • A quick tour
  • Bundled libraries and modules
  • Downloading and installing from CPAN
  • Case study: Using Getopt::Long

Session: Creating Modules

  • Review of subroutines
  • Understanding my () and local ()
  • Packages and the symbol table
  • Mechanics of module creation
  • Exporting subroutines and data
  • Using BEGIN and END
  • Good module design

Session: Classes

  • Perl's approach to Classes
  • Understanding bless
  • Constructors
  • Methods
  • Properties
  • Inheritance

Session: Exception handling

  • Simple exception handling
  • Trapping exceptions
  • Using Carp, Croak, and Cluck
  • Raising exceptions

Session: Sys Admin Part 2

  • Monitoring files
  • Accessing syslog
  • Network information
  • User management

OPTIONAL ITEMS | As time permits:

Session: Network Tools

  • Copying files across the network
  • Remote login
  • Grabbing data from the Web

Session: Serializing Data

  • Available tools
  • Storable
  • JSON

Session: Enterprise Development

  • Coding standards
  • Source code tools
  • Core modules
  • Saving time with module-starter
  • Documenting with POD
  • Benchmarking and Profiling
  • Unit testing
  • Distributing and installing modules

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Course Materials

Our course materials include more than a simple slideshow presentation handout. Each student will receive a comprehensive course Student Guide, complete with detailed course notes, code samples, software tutorials, diagrams and related reference materials and links. Our courses also include detailed our Student Workbook, with step by step hands-on lab instructions and code samples, clearly illustrated for users to complete hands-on work in class, and to revisit to review or refresh skills at any time.  Students will also receive the course set up files and project code needed for the hands on work.

Raise the bar for advancing technology skills

Attend a Class!

Live scheduled classes are listed below or browse our full course catalog anytime

Special Offers

We regulary offer discounts for individuals, groups and corporate teams. Contact us

Custom Team Training

Check out custom training solutions planned around your unique needs and skills.

EveryCourse Extras

Exclusive materials, ongoing support and a free live course refresh with every class.

Summer Savings!
Register today to receive *50% off all 2021 Public Classes*!  Check out our Current Offers for Individuals, Teams and Organizations to Learn for Less!

See our latest Offers and Promotions

Learn. Explore. Advance!

Extend your training investment! Recorded sessions, free re-sits and after course support included with Every Course
Trivera MiniCamps
Gain the skills you need with less time in the classroom with our short course, live-online hands-on events
Trivera QuickSkills: Free Courses and Webinars
Training on us! Keep your skills current with free live events, courses & webinars
Trivera AfterCourse: Coaching and Support
Expert level after-training support to help organizations put new training skills into practice on the job

The voices of our customers speak volumes

Special Offers
Limited Offer for most courses.

SAVE 50%

Learn More