Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read.

Similar presentations


Presentation on theme: "Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read."— Presentation transcript:

1

2 Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read assignments Upcoming deadlines Lab assistance, questions and answers

3 Link of the week Data Disaster Ontrack Data Recovery http://www.ontrackdatarecovery Ironkey USB Flash Drive https://www.ironkey.com/demo-enterprise Data Disaster Helpful Hints - Use dedicated circuits for your connection - Keep your computer cool and in a dry place - Use a UPS (Uninterrupted Power Supply) - Don’t assume that your data is permanently destroyed even if the situation looks bad - Secure your work area and devices -

4 Link of the week Data Disaster 1.Big and small company operations 2.Backup services 3.Trouble shooting 4.Data recovery

5 Review week four lab assignment What is an object file? Object code is a representation of code generated by a compiler after it processes a programming language code file. It contains compact, pre-parsed code, often referred to as binaries that can be linked with other object files to generate a final executable.

6 Review week four lab assignment What is ELF? Executable and Linking Format (ELF) is a common standard file format for executables, object code, shared libraries, and core dumps.

7 Review week four lab assignment Perl Syntax ;end of statement delimiter,comma for line continuation \nnew line (non-printable character) Perl Variable Syntax $ singular variables prefix (single value, number or string) @ prefix for plural variable (array) %prefix for plural variable (hash) $_ default variable

8 Review week four lab assignment Perl Syntax while ( … ) { Action statements } If ( …) { Action statements }

9 Review week four lab assignment Perl Syntax If ( … ) { Action statements } else { Action statements }

10 Review week four lab assignment Relational Operators NumericStringMeaning > gtGreater than >= geGreater than or equal to < ltLess than <= leLess than or equal to

11 Review week four lab assignment Equality Operators NumericString Meaning == eq Equal to != ne Not equal to  cmp Comparison with signed result The  or cmp operators return 1 if the left operand is less than the right operand, 0if they are equal, and +1 it the left operand is greater than the right.

12 Review week four lab assignment Definition: array Arrays are an ordered list of scalars, accessed by the scalar’s position in the list. Otherwise known as a collection of scalars. In Perl, a scalar means the simplest data type which was designed to hold only one thing like a number, a string or a reference. Elements in an array are accessed by using an index. Array indexes start with zero.

13 Review week four lab assignment Array and Variable Initialization Initialize an array: @garage = (“rake”, “mower”, “shovel”); @persons = (“Will”, “Ken”, “Hazel”, “Jay”); $count = @persons; Unload array elements into variables: ($rake, $mower, $shovel) = @garage

14 Review week four lab assignment Array Data Structures array of arrays – Two-dimensional array or a matrix @names = ( [ “Sam”, “Clide”, “Kim” ], [ “Melinda”, Terri”, “Sissy” ] [ “Fred”, “Omar”, “Vincent” ] ); print $names [1] [1];

15 Review week four lab assignment Definition :Hash (associative array) A hash is similar to an array only because it contains a number of scalars. A hash is different in the case where the element of a structure represents a pair – a key and a value. Whenever we refer to an element of a Perl hash structure, we mean a pair (key and value) which links a value to a key. We have access to the elements of a hash variable by a scalar key. Hash table is an unordered set of scalars, accessed by some string value that is associated with each scalar.

16 Review week four lab assignment Hash Initialization %student_ages = ("John", 43, "Paul", 25, "Marie", 22); %members = (John => "father", Paul => "son", Marie => "daughter"); The comma-arrow (=>) operator is used to initialize the %members hash variable in the second line of code. The left side of the comma- arrow operator is expected to be a simple string and therefore it is not necessary to be quoted.

17 Review week four lab assignment Hash Initialization (con’t) %all_groups = ( group_name1 => [ “Betty”, “Tom” ], group_name2 => [ “Ali”, “Marcia” ]’ ); $all_groups{group_name1} [3] = “Sam”; for $couple ( keys %all_groups ) { print “$couple; @{$all_groups{$couple} }\n; }

18 Review week four lab assignment Hash Copy %school_ages = %student_ages

19 Review week four lab assignment Hash Table Example %colormap=( “12” => “gray”, “19” => “black”, “30” => “red”,); %colormap = (“12”, “gray”, “19”, “black”, “30”, “red”);

20

21 Review week four lab assignment

22 Perl utilizes two types of categories - Singular variables that represent a single-value. The variable prefix symbol for a scalar is the $. - Plural variables are ones that contain multiple-values. Arrays and hashes are two multi-valued variables. Perl data types $answer = 42; (an integer) $pi = 3.14159265;(a “real” number) $animal = “horse”; (string) $statement = “I exercise my $animal”; (string with interpolation) $amount = ‘It cost me $5.00’; (string without interpolation) $cwd = `pwd`; (string output from a command)

23 Review week four lab assignment Filehandle is utilized for both input and output files. Most file names are cryptic and are meaningless to programmers. The purpose of a filehandle is to help the programmer remember a simple file name throughout a program. A filehandle is a name given for a file, device, socket, or pipe. Filehandle command line format: open(filehandle, file name, permissions, chmod); Example: open($FH,$file_name);

24 Review week four lab assignment Practice scripts under ~dandrear/tmp directory arry_sort.pl read_list.pl sum_list.pl person.sh hash_table.pl two_dim.pl week_four.pl

25 Weeks four and five expected outcomes Write Perl scripts, including variables, control flow, and regular expression syntax

26 Next lab assignment Regular Expressions Search programs - grep and findstr. Text language programs - sed and awk Text editors – iv and emac Many other languages use regular expressions and may advertise a particular Perl version.

27 Next lab assignment Regular Expression Special Characters Open square bracket [ Backslash\ Caret^ Dollar sign$ Dot. Pipe symbol| Question mark? Asterisk* Plus sign+ Opening and closing round brackets( )

28 Next lab assignment Regular Expression (a.k.a. regex or regexp) Is a pattern that describes a certain amount of text. A basic regular expression could be the single character, e.g.: a Jack is a guy. It will match the first occurrence in the string. If succeeding matches are desired, the regex engine must be instructed to do so.

29 Next lab assignment Character Classes match only one out of several characters, e.g.: [ae] and gr[ae]y The order of the characters inside a character class doesn’t matter. Shorthand Character Classes match single characters, e.g.: \d and \w and \s Non-Printable Characters are special character sequence to put non-printable characters in your regular expression, e.g.: \t and \r and \n and \a and \e and \v

30 Next lab assignment Dot matches almost any character, except line break characters, e.g.:gr.y Anchors match a position. Match start of string^ Match end of a string$ Alternation is the regular expression equivalent of “or”. The search pattern bird | insect will first return “bird. The second match will be “insect”.

31 Next lab assignment makefile Lab Assignment Copy the test_build.sh script from ~dandrear/tmp directory This script executes the make command which in turn executes the makefile Demonstrate Execute ~dandrear/temp/test_build.sh script View the test_build.sh script

32 Next lab assignment Programming Perl, Chapter 32 Standard Modules Define: Module Parsing the command line with Getopt::Std Example: listdir –l –n –a 10:00 bottom top Perl utilizes @ARGV to capture the command line arguments Example: $ARGV[0] ‘-l’ $ARGV[1]‘-n’ $ARGV[2]‘-a’ $ARGV[3]’10:00’ $ARGV[4]‘bottom’ $ARGV[5]‘top’

33 Break-out problems Define a Perl hash table ELF Define a Perl array Perl Filehandle Regular expression How is an element in an array accessed? Object file Define common-arrow Perl default variable AES

34 Reading assignments Reading Assignment Essential System Administration Chapter One Chapter Two Chapter Three Programming Perl Chapter One Chapter Two Chapter Three Chapter Four Chapter Thirty Two

35 Upcoming deadlines Makefile Exercise, 6-2 is due 2/22/09. Programming Assignment 1, 6-1 is due 3/1/09. Mid-term exam dates 10/20/08 through 2/16 - 21/09. Mid-term exam, 7-1 is due 2/2/09. Script logic for the above assignment will be emailed at the end of the week.

36 Questions and answers Questions Comments Concerns After class I will help students with their scripts.


Download ppt "Week Five Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Read."

Similar presentations


Ads by Google