Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.

Similar presentations


Presentation on theme: "Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist."— Presentation transcript:

1 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist

2 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 1: Introduction to Perl

3 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Describe the benefits of Perl Explain the role of the Perl interpreter Identify the characteristics of Perl’s basic syntax Describe the use of the print function Create and execute a simple Perl script Define scalar variables Use scalar variables to manipulate numerical and string data Use expression operators Retrieve data from STDIN

4 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Practical Extracting and Reporting Language Why use Perl? –Innate flexibility –Simple syntax –Relaxed compiler instructions –Free

5 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Getting Started with Perl The shebang line Creating a simple Perl script

6 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Scalar and Numerical Variables Assignment Expressions

7 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved String Variables Second type of scalar variable The print function

8 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Retrieving Data from STDIN The chomp() function

9 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Describe the benefits of Perl Explain the role of the Perl interpreter Identify the characteristics of Perl’s basic syntax Describe the use of the print function Create and execute a simple Perl script Define scalar variables Use scalar variables to manipulate numerical and string data Use expression operators Retrieve data from STDIN

10 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 2: Flow Control in Perl

11 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Evaluate Boolean expressions Construct an if statement Discuss else and elsif branches Construct a while loop Construct a do {} while loop Construct a for loop Use loop labels Describe the I/O redirection paradigm

12 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Boolean Expressions in Perl Numeric Boolean expressions String Boolean expressions Logical operators

13 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The if Statement The else branch The elsif branch

14 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The while Statement Second type of control structure Defines a block of code that will be executed repeatedly as long as some Boolean expression evaluates as true

15 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The do { } while Statement Similar to the while loop except that the condition is not evaluated until the code block has already been executed once

16 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The for Statement Includes three expressions separated by semicolons Incorporates facilities for initializing a counter and incrementing it on each turn through the code block

17 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Loop-Control Commands last next redo

18 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved I/O Redirection Many Perl scripts use I/O redirection in place of more complicated file-handling subroutines

19 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Evaluate Boolean expressions Construct an if statement Discuss else and elsif branches Construct a while loop Construct a do {} while loop Construct a for loop Use loop labels Describe the I/O redirection paradigm

20 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 3: Regular Expressions in Perl

21 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Define regular expressions Perform pattern matching Define and use metacharacters Explain character classes Define quantifiers and assertions Perform substitution Use the binding operator

22 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Regular Expressions Pattern binding operators Escape sequences and metacharacters

23 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Character Classes Indicate a list of characters that one element in a string will match

24 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Pattern Matching and Substitution Back references

25 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Define regular expressions Perform pattern matching Define and use metacharacters Explain character classes Define quantifiers and assertions Perform substitution Use the binding operator

26 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 4: Arrays in Perl

27 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Describe the purpose of arrays Define arrays using lists Access array elements Use the sort function to sort an array alphabetically Use a foreach loop to traverse an array Use the push and pop functions Use the shift and unshift functions Use the split and join functions

28 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Perl Arrays Initializing arrays Accessing array elements

29 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The sort Function Accepts an array as an argument, alphabetizes the elements within the array, and returns the resultant array

30 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The foreach Statement A special control structure designed to iterate through an array or list

31 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The push and pop Functions The push function adds values to the top of a stack The pop function removes values from a stack

32 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The shift and unshift Functions The unshift function adds a value to the front of an array and shifts the rest of the array by one The shift function removes values from an array Using an array as a queue

33 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The split and join Functions The split function accepts two arguments, a regular expression and a string The join function accepts a list of values and combines them into a single string

34 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Describe the purpose of arrays Define arrays using lists Access array elements Use the sort function to sort an array alphabetically Use a foreach loop to traverse an array Use the push and pop functions Use the shift and unshift functions Use the split and join functions

35 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 5: Hashes in Perl

36 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Describe the purpose of hashes Define hashes using lists Access hash elements Use the delete function Use the keys function Use the values function Use the each function Use the reverse function

37 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Perl Hashes Hashes are collections of scalar values that can be accessed individually Hash elements are accessed using an arbitrary scalar value, called a key Also known as associative arrays

38 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Adding and Deleting Hash Elements The delete function The keys function The values function The each function The reverse function

39 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Describe the purpose of hashes Define hashes using lists Access hash elements Use the delete function Use the keys function Use the values function Use the each function Use the reverse function

40 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 6: Subroutines in Perl

41 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Define and use a subroutine Call subroutines directly and indirectly Pass values to a subroutine Return a value from a subroutine Explain variable scope Pass references to a subroutine

42 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Perl Subroutines Defining subroutines Calling subroutines Passing arguments Returning values The sort function and subroutines

43 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Variable Scope Variables can be created within subroutines that are private (specific) to just that subroutine using the my operator –The my operator takes a scalar, array, or hash name and instantiates local versions inside a subroutine

44 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved References Creating and referencing anonymous arrays Creating and referencing anonymous hashes Passing references to subroutines

45 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Define and use a subroutine Call subroutines directly and indirectly Pass values to a subroutine Return a value from a subroutine Explain variable scope Pass references to a subroutine

46 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 7: File Input and Output

47 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Define and use filehandles Obtain a filehandle using the open function Output data to a file Close a file using the close function Open a file for reading Use the stat and lstat functions to obtain information about a file

48 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl File Input and Output What is a filehandle? The open function Outputting data to a file Opening files for reading Other file-related functions Determining information about files The stat and lstat functions

49 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Define and use filehandles Obtain a filehandle using the open function Output data to a file Close a file using the close function Open a file for reading Use the stat and lstat functions to obtain information about a file

50 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 8: Environment Variables and Command Line Arguments

51 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Access and use environment variables Use command line arguments Define options when handling command line arguments

52 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Environment Variables What are environment variables? –Shells

53 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Command Line Arguments Arguments entered at the command line can be used in Perl programs

54 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Access and use environment variables Use command line arguments Define options when handling command line arguments

55 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 9: Packages and Modules in Perl

56 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Describe the purpose of packages Use the package keyword Use BEGIN and END blocks Describe the purpose of modules Create a module to facilitate code reuse Incorporate a module into your Perl scripts using the use and require statements Use the Exporter module

57 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Using Packages in Perl Namespace The package keyword Package symbol tables

58 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved BEGIN and END Blocks Special blocks of code defined within a package

59 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Using Modules in Perl Specially designed Perl scripts that package functionality for reuse by other Perl scripts

60 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The use and require Statements The require statement takes a single argument (the name of the module to include) The use statement adds symbols directly to the including package’s symbol table

61 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Describe the purpose of packages Use the package keyword Use BEGIN and END blocks Describe the purpose of modules Create a module to facilitate code reuse Incorporate a module into your Perl scripts using the use and require statements Use the Exporter module

62 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 10: Object-Oriented Perl

63 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Describe the purpose of objects Define objects for use in your Perl scripts Access object data Define and use object methods Use inheritance to expand the functionality of a class

64 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Object-Oriented Perl Creating objects Object data Object methods

65 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Inheritance @ISA array Destructor methods

66 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Describe the purpose of objects Define objects for use in your Perl scripts Access object data Define and use object methods Use inheritance to expand the functionality of a class

67 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 11: Database Connectivity and Perl

68 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Define database programming Explain the benefits of using a database Define and use the Database Interface Module (DBI) Define and use the Database Driver Module (DBD) Open a database connection Close a connection to a database Query a database Define and use the Structured Query Language (SQL) Return records from a database Insert records into a database

69 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Database Connectivity Database programming Database Interface Module Database Driver Module

70 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Interacting with Databases 1. Connect to the database 2. Query the database 3. Display the results 4. Close the connection

71 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Connecting to Databases The connect method

72 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Structured Query Language Data Definition Language –CREATE –DROP Data Query Language Data Manipulation Language –INSERT –DELETE –UPDATE

73 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Quoting Operators Perl includes quoting operators that can be used instead of single or double quotation marks

74 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Define database programming Explain the benefits of using a database Define and use the Database Interface Module (DBI) Define and use the Database Driver Module (DBD) Open a database connection Close a connection to a database Query a database Define and use the Structured Query Language (SQL) Return records from a database Insert records into a database

75 Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Lesson 12: Debugging Perl Programs

76 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Objectives Debug Perl programs Use the –w switch Use the strict module Trace the execution of a Perl script Issue commands to the Perl debugger Design Perl scripts to minimize bugs

77 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Introduction to Debugging Perl Scripts Using the print command Using the –w switch Using the strict module

78 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved The Perl Debugger Traps and fixes errors in a Perl script An interactive Perl environment wherein the user is prompted for debugger commands

79 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Writing Bug-Free Perl Code Preventing errors Common Perl errors

80 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Summary Debug Perl programs Use the –w switch Use the strict module Trace the execution of a Perl script Issue commands to the Perl debugger Design Perl scripts to minimize bugs

81 Perl Specialist Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist Introduction to Perl Flow Control in Perl Regular Expressions in Perl Arrays in Perl Hashes in Perl Subroutines in Perl File Input and Output Environment Variables and Command Line Arguments Packages and Modules in Perl Object-Oriented Perl Database Connectivity and Perl Debugging Perl Programs


Download ppt "Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist."

Similar presentations


Ads by Google