Programmering - Perlscript

(4 dagar)

Perl Programming

Perl is an interpreted programming language, optimised for scanning text files, extracting information from files and generating reports based on the obtained information. It is capable of scanning large amounts of data in a very quick manner. It is also capable of dealing with binary data. Perl is used by system administrators, programmers and network designers for data manipulation, WWW programming for parsing and generating HTML, controlling mail, CGI programming, etc.

Perl is usually associated with Unix, its source code is available for free, and implemented on most operating systems (including all versions of Microsoft Windows and .Net, Mac, VMS as well as mainframe MVS and OS400). The course is run on a Linux platform, but is applicable to other operating systems.


On Completion, Delegates will be able to

  • Use all significant features of the Perl 5 programming language
  • Develop Perl programmes containing advanced Perl constructs
  • Read and understand the extensive Perl reference manual
  • Implement advanced data stream handling
  • Use functions, modules, and subroutines
  • Run and control external programs
  • Write programmes manipulating files and directories
  • Write powerful report generating programmes implementing Regular Expressions

Appreciate the mechanisms involved in Object Oriented Programming with Perl

Who Should Attend
Experienced system administrators seeking to write fast, powerful and efficient report generating programs to manipulate data files and logs.

Programmers and analysts intending to implement Perl programs, e.g. HTML generation, application control, and report generation.


Course Style
Lectures have an accompanying practical session relating not only to the newly covered material, but to material and solutions from earlier sessions, allowing realistic examples to be considered. Hard copies of all exercises and solutions are provided. 

Prerequisites
Developers must have a working knowledge of a programming language, perhaps gained from attending a programming course, or equivalent knowledge. Prior knowledge of Unix is an advantage, but not an absolute necessity.

Typically, delegate skills will include good experience in a structured high-level programming language, preferably C, C++ or Java, a working knowledge of the Unix operating system and experience in shell programming. A strong understanding of computer systems and data administration is beneficial, as Perl provides a common solution to a variety of platforms.

Those who intend to use Perl for writing administrative tools may choose to follow the Mastering UNIX Shell Scripts and UNIX Advanced Data Tools and Techniques course path to gain sufficient pre-requisite experience.


   

Course Content

Language Basics
Perl documentation; Perl history and application; Environment; Script structure, command line and execution; Pragmas; Perl script examples

Perl Variables
Scalars, Arrays, Hashes; Literals; Slices; undef; system variables

Operators and Expressions
Numeric and string expressions and operators; Context conversion; globbing

Functions
String functions; Array functions; Hash functions

Flow control
Conditional statements; for loop; Entry and exit loops; Local variables; Shorthand conditional statements; Scoping rules; exit; die; File conditional operators; Exception handling with eval

Input and Output
File handles; Reading and writing files; Constructing filters; Changing the default file handle

Running processes
Process relationaships; Back ticks; The system function; wait & waitpid; Special variables; fork and exec; Anonymous pipes

Subroutines and Modules
Definition; Calling and returning from; Subroutine arguments, return values and prototypes; Module structure; Using modules; Standard modules and libraries

Report generating
printf; Creating reports and formats; Multi-line formats; Output generation; Special formats' variables

Regular Expressions
Basic and extended set of RE characters; Alternatives and grouping; Character classes; Search and replace with expressions; Side effect variables; Dynamic pattern details; Quantifiers; Minimal matching

Advanced Array Functions
Sort function; Customising sort order; Sorting Hashes and objects; grep; map

References
Definition and purpose of references; Creating, using and examining references; References and subroutines

Introduction to Object-Oriented Programming
Perl OO basics and features; Accessing object fields; Basic Constructors; method calls; Destructors, inheritance

The following additional topics are documented in appendices, but not formally covered :
File System Interaction; Network Programming; DBI Database Interfacing; Introduction to CGI Programming; Advanced Regular Expressions; Signal Handling