Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines Questions and answers
Link of the week Object Code What is object code? What format is object code in? How are object files applied where large systems are packaged?
Link of the week
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 ~ Shell $# Perl $ARGV[0] ~ Shell $1 Perl $ARGV[1] ~ Shell $2 Perl ~ 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 failed 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`;
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
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 = ; (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 = (“car”, “mower”, “broom”); (an array is an ordered list of scalars, accessed by the scalar’s position in the list)
Next Lab Assignment The first element of an array starts at the zero index. 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); A filehandle may be passed four arguments.
Next Lab Assignment What is List = (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) { … = ('Larry', 'Curly', 'Moe'); foreach { print $_; }
Next lab assignment #!/usr/bin/perl script statement Print continuation statement print "error: incorrect number of arguments", "\n", "usage: intlist a b (where a < b)", "\n"; Demonstrate Lab Assignment 5-1 script logic on cs.franklin.edu (Einstein) (lab_51_Online_Script_Logic)
Next lab assignment Programming Perl text book reading Chapter One, pages 20 – 28, 30 – 33, 41 – 43, Online reading Chapter One Filehandles Operators Some Binary Arithmetic Operators String Operators
Next lab assignment Online reading Chapter One Assignment Operators Logical Operators Some Numeric and String Comparison Operators The if and unless statements Iterative Constructs The while and until statements The for statement Built-in Data Types Variables Names Name Lookups Scalar Values Numeric Literals String Literals Pick Your Own Quotes Or Leave the Quotes out Entirely Interpolating Array Values List Processing
Break-out problems $strexp = “This text is considered as a string”; $intexp = 10; $floatptexp = 2.54; $charexp = ‘a’; $cmdexp = `ls –l`; $argexp = (“two”, “four”, = (“Jackie”, “Vicki”, “Alex”); $arrayexp[0] = “new value”; $a = $b + = (“car”, “boat”, “truck”); $container ($map{blue}, $map{orange}, $map{jade}) = (0xff0000, 0x00ff00, 0x0000ff0);
Upcoming deadlines Advanced Shell Script, 4-1 is due 5/25/08. Simple Perl Script, 5-1 is due 6/1/08. Mid-term outline to be posted on Bulletin Board by 5/26/08 Mid-term exam date 6/9-14/08.
Questions and answers Questions Comments Concerns After class I will help students with their scripts.