Advanced Perl 5 Programming

מק"ט: #42602 | משך קורס: 32 שעות אק'

This course takes delegates beyond the basic syntax and structure of Perl. It answers questions like how do Perl variables really work, and what tools are available to improve my code, or the code I have inherited?
It delves into details such as UNIX and Windows file directory structures, and how to exploit them, how to store complex Perl data structures in files and databases, and the strengths and weaknesses of different techniques.
Object Orientation techniques are the norm now, yet many Perl programmers have lagged behind. This course gives a through grounding of OOP techniques in Perl, including inside-out objects and an overview of the future of Perl OO – Moose.
Interfacing with low-level 3rd-party products usually requires a C interface, but Perl has XS which enables C – Perl communications. Perl XS requires a deep understanding of how Perl and Perl variables work and are manipulated – all covered in this course (an understanding of C really will help here).
Finally we take a look at multi-threading, its concepts, and Perl specifics.
Every effort is made to maintain the course material at the very latest release of Perl, and new features will be discussed.

הקורס פעיל לקבוצות מטעם ארגונים בלבד, ניתן לשלוח פנייה רק אם מדובר בקבוצה
*שדות חובה
PDF version

מטרות

  • Use advanced features of the Perl 5 programming language
  • Use tools and techniques to improve existing Perl 5 code
  • Understand the impact of Perl 5 variable types, and how they are stored
  • Write robust modules installation packages with tests
  • Use and choose appropriate Perl Object Orientation techniques for large projects
  • Appreciate the depth and advantages of Moose
  • Understand and interfaces between Perl and a C API
  • Understand multi-threading in Perl 5
  • Use DBI interface and DBD modules to connect to a database
  • Write programs to facilitate network communication

קהל יעד

This course is suitable for programmers and system administrators.

תנאי קדם

Students should be familiar with Perl to the level of the 42601 course and have recent experience of programming in Perl. Ideally that would be obtained by attending the course; if self-taught then the delegate should have experience at least to the level of the O’Reilly book ‘Intermediate Perl’.
It is assumed that delegates are familiar with references, subroutines, and using modules; although in all cases some revision is offered.
Knowledge of C would be an advantage, and is assumed for the chapter “Embedding and Extending Perl 5”.

 

נושאים

Chapter 1 Revision

  • Course objectives
  • Perl documentation
  • Perl history
  • Modern Perl
  • What is Perl 6?
  • Interpreter environment
  • Running a perl script
  • Anatomy of a perl script
  • Perl variables
  • Reminder: variable definitions
  • Some short-cut operators
  • Arrays and lists
  • Lexical variables
  • Controlling the interpreter – Pragmas
  • Always use strictures
  • Lexical pragmas
  • Creating references
  • Using references
  • Dereferencing array and hash references

 

Chapter 2 The Perl 5 Language Environment

  • Some useful literal constants
  • Perl debugging
  • The Devel namespace
  • Profiling perl code
  • Benchmark
  • Warnings and diagnostics
  • Controlling warnings
  • Compiler back ends
  • De-compiler
  • Perl::Tidy
  • Perl::Critic
  • Perl Archive Toolkit – PAR
  • Data::Dumper

 

Chapter 3 Files and Directories

  • The role of the directory on UNIX
  • The role of the directory on Windows
  • Perl functions for directories
  • Get current working directory
  • Working with directory entries – UNIX
  • Perl functions for directory entries
  • Monitoring directory changes – Linux
  • Adding a watch and reading events
  • Monitoring directory changes – Windows
  • Win32::ChangeNotify – example
  • Detailed file information
  • Stat conversion
  • UNIX symbolic links
  • Perl functions for UNIX symbolic links
  • Altering UNIX access permissions
  • Windows access validation
  • Access permissions on Windows
  • Reading directories
  • Positioning in directories
  • Windows Alternative Data Streams

 

Chapter 4 Data Persistence

  • Perl file handling – revision
  • Scalar variables with handles
  • Alternative IO functions
  • So I have a variable, how do I save it?
  • The tie interface
  • Using tied modules
  • Implementing your own tie
  • Copying references – problem
  • Data::Dumper – writing data
  • Data::Dumper – get the data
  • YAML – YAML Ain’t a Markup Language
  • YAML – get the data
  • Storable
  • Storable – managing our own IO
  • Storable – getting the data stream
  • Storable to the rescue – dclone
  • Other persistence packages

 

Chapter 5 Modules

  • Splitting into modules
  • Using modules
  • Conditional use
  • The library directories
  • Removing directories from @INC
  • @INC hooks
  • Use versus require
  • Namespaces
  • Using subroutines from modules
  • Example of unconditional export
  • Example of on-demand export
  • Symbol export using tags
  • Conditionally exporting at run-time
  • Creating a module
  • Multiple packages per module
  • Writing tests

 

Chapter 6 Overview of Perl 5 Object Orientation

  • Review of Object Oriented Programming
  • To OO, or not to OO?
  • Basic object usage
  • Objects are references
  • Implementing Objects
  • Accessing object fields
  • Constructors
  • Implementing object methods – details
  • Method calls

 

Chapter 7 Constructors and Destructors

  • Object constructors
  • Object destructors
  • Reference counting
  • Object data types – pre 5.10
  • Object data types – post 5.10
  • Named constructors
  • Classic polymorphism
  • Virtual constructors
  • Virtual constructors – exemplar registry
  • Virtual constructors – base class
  • Singletons

 

Chapter 8 Inheritance and OverloadingMethod inheritance

  • The parent pragma – 5.10.1 or later
  • Constructor inheritance
  • Multiple inheritance order
  • SUPER class – which one?
  • UNIVERSAL class
  • Alternatives to UNIVERSAL
  • Operator overloading
  • Operator overloading – the details

 

Chapter 9 Encapsulation

  • Defining object layout
  • The fields pragma
  • Implementing methods with strong typing
  • Perl encapsulation?
  • Inside-out objects
  • Inside-out object destructors
  • Access method: shared or separate?
  • Inside-out accessors

 

Chapter 10 Introduction to Moose

  • Moose is the new camel
  • Moose or Mouse?
  • Basic Moose
  • Attributes
  • Further attribute options
  • Constructors and Destructors
  • Example BUILDARGS
  • Methods
  • Inheritance
  • Overriding the super class
  • Derived class BUILDARGS
  • Roles and delegation

 

Chapter 11 Embedding and Extending Perl 5

  • UNIX specific syscall
  • Converting between Perl and C
  • syscall and unpack examples
  • Interfacing with Perl internals
  • Typeglobs and stashes
  • Decoding Devel::Peek
  • Primitive data types
  • How are lexical variables held?
  • Extensions – the principle
  • What is XS?
  • XS code entry points
  • The BOOT section and globals
  • Passing arguments
  • Creating Perl variables
  • Getting Perl variable values
  • Returning scalars
  • Returning lists by value
  • Error handling
  • Alternative to XS – Inline

 

Chapter 12 Multi-threaded Programming

  • Review of threads
  • Review of thread concepts
  • Threads in Perl
  • Perl threads example
  • Sharing data between threads
  • Using subroutine attributes
  • Synchronisation
  • Caveats and bugs
  • Thread safety
  • Double-check
  • CLONE
  • Threads, processes and applications

 

Extended Topics

 

Chapter 13: Object Oriented Programming

  • Review of Object Oriented Programming
  • Object-Oriented terminology
  • OO features in Perl
  • Basic object usage
  • Objects are references
  • Implementing objects
  • Accessing object fields
  • Constructors
  • Implementing object methods – details
  • Method calls
  • Destructors
  • Method inheritance
  • The parent pragma – 5.10.1 or later
  • Inheriting constructors
  • To OO, or not to OO?

 

Chapter 14: Database Interfacing Using DBI

  • Perl and databases
  • The tie interface
  • Tie-ing a hash to a GDBM file
  • DBI and DBD
  • DBI objects and methods
  • Connect and disconnect
  • Driver issues with MS SQL Server
  • Options for connect
  • Life cycle of a statement
  • Placeholders
  • Reading information
  • Fetching database meta-data
  • Repeated statement execution
  • Other database handle methods
  • Database capabilities
  • Manual transaction control
  • Error handling
  • Calling a stored procedure
  • Other DBI drivers
  • Yet more DBI drivers

 

Chapter 15: Network and Web Programming

  • Networking concepts: layers and sockets
  • Sockets are file handles
  • A basic client
  • A basic server
  • Network modules: FTP client
  • Network modules: web client
  • Network modules: sending mail
  • Program generated web pages
  • Secure Perl – taint mode
  • Running a CGI script
  • Using HTML from Perl
  • A simple CGI script
  • CGI.pm basic functions
  • Form handling using CGI.pm
  • Templates
  • Frameworks
תגיות