270 likes | 364 Views
Week Four Agenda. Announcements Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines Lab assistance, questions and answers. Link of the week. Object Code http://en.wikipedia.org/wiki/Object_code
E N D
Week Four Agenda • Announcements • Link of the week • Review week three lab assignment • This week’s expected outcomes • Next lab assignment • Break-out problems • Upcoming deadlines • Lab assistance, questions and answers
Link of the week Object Code • http://en.wikipedia.org/wiki/Object_code • What is object code? • What format is object code in? • How are object files applied where large systems are packaged? • What is Executable and Linking Format?
Review week three lab assignment Perl is a simple language that compiles and executes like a shell or batch type file. Perl doesn’t impose special growth limitations on an array or data strings Perl is a composite of C, AWK, and Basic. Perl was originally developed to manipulate text information.
Review week three lab assignment • Perl’s capabilities range from - System administration - Web development - Network programming - GUI development • Perl’s major features are • Procedural Programming makes use of simple sequential steps, routines, subroutines, and methods. • Object Oriented Programming (OOP) makes use of “objects”. The key elements of are inheritance, modularity, polymorphism, and encapsulation.
Review week three lab assignment Perl scalar@ARGV ~ Shell $# Perl $ARGV[0] ~ Shell $1 Perl $ARGV[1] ~ Shell $2 Perl unless(scalar(@ARGV)==2) ~ Shell if [ $# != 2] All Perl statements are terminated with a “;” Perl exit 0 is returned if execution was successful Perl exit 1 is returned if execution fails The return value for a child process is returned to the parent process when the child process terminates.
Review week three lab assignment $? – this variable contains the return value # - precedes a comment statement in Perl \n - new line syntax “ …” $strexp = “This text is considered as a string”; ‘ …’ $charexp = ‘a’; ` …` $cmdexp = `ls –l`; @ARGV – array containing command line arguments $_ - default implied scalar
Review week three lab assignment A process associates a number with each file that it has opened. This number is called a file descriptor. When you log in, your first process has the following three open files connected to your terminal. Standard Input (stdin) : Filedescriptor 0 is open for reading. < really means <0 Standard Output (stdout): File descriptor 1 is open for writing. > really means 1> Standard Error (stderr): File descriptor 2 is open reading. >> really means 1>>
Review week three lab assignment The open function can be used to create file handles for different purposes (input, output, piping), you need to be able to specify which behavior you want. open functions open(file_handler, “file_name”) open(file_handler, “<file_name”) open (file_handler, “>file_name”) open (file_handler, “>>file_name”)
Review week three lab assignment There are two types of relational operators. One class operates on numeric values, the other on string values. Relational operators NumericStringMeaning > gt Greater than >= ge Greater than or equal < lt Less than <= le Less than or equal
Review week three lab assignment Equality Operators NumericStringMeaning == eq Equal to != ne Not equal to cmp Comparison, sign results -1 if the left operand is less 0 If both operands equal 1 If the left operand is greater
Week four expected outcomes • Write Perl scripts, including variables, control flow, and regular expression syntax
Next lab assignment • Perl is designed to - Process text data - Perform pattern matching - Utilize string handling tasks • Perl is available on many platforms - UNIX - Linux - HP-UX
Next Lab Assignment 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)
Next Lab Assignment @garage = (“car”, “mower”, “broom”); Definition: An array is an ordered list of scalars, accessed by the scalar’s position in the list. @persons = (“Will”, “Karim”, “Asma”, “Jay”); $count = @persons; Demonstrate: Execute week_four.pl script
Next 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);
Next Lab Assignment What is List Processing? @math_array = (6 - 4, 4 * 4, 8 / 2, 9 - 8); while ( … ) { … } for (counter = 0; counter < 10; counter++) { … } Three expressions are contained in a for loop: • Set initial state of the loop variable • Condition test the loop variable • Modify the the state of the loop variable
Next Lab Assignment foreach VAR (List) { … } Demonstrate: Execute read_list.pl script @myNames = ('Larry', 'Curly', 'Moe');foreach (@myNames) { print $_;} Demonstrate: Execute sum_list.pl script
Next lab assignment Perl Program Statement #!/usr/bin/perl #!/usr/bin/perl -w Print continuation statement print "error: incorrect number of arguments", "\n", "usage: intlist a b (where a < b)", "\n"; Demonstrate: Execute linenum.pl and intlist.pl scripts.
Next lab assignment Demonstrate Execute arry_sort.pl script
Next lab assignment Programming Perl text book reading Chapter One Chapter Two Chapter Three
Break-out problems • $strexp = “This text is considered as a string”; • $intexp = 10; • $floatptexp = 2.54; • $charexp = ‘a’; • $cmdexp = `ls –l`; • $argexp = (“two”, “four”, “six”); • @arrayexp = (“Jackie”, “Vicki”, “Alex”); • $arrayexp[0] = “new value”; • $a = $b + 5; • $container = @container; • ($map{blue}, $map{orange}, $map{jade}) = (0xff0000, 0x00ff00, 0x0000ff0);
Upcoming deadlines • Advanced Shell Script, Lab Assignment 3-1 is due 2/1/09. • Simple Perl Script, Lab Assignment 4-1 is due 2/8/09. • Mid-term outline to be posted on Bulletin Board by 2/1/09 • Mid-term exam, Lab Assignment 7-1 dates 2/16-21/09.
Questions and answers • Questions • Comments • Concerns • After class, I will help students with their scripts.