Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1

2 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 Questions and answers

3 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?

4 Link of the week

5

6 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.

7 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.

8 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.

9 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

10 Week four expected outcomes Write Perl scripts, including variables, control flow, and regular expression syntax

11 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

12 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)

13 Next Lab Assignment @garage = (“car”, “mower”, “broom”); (an array is an ordered list of scalars, accessed by the scalar’s position in the list) @persons = (“Will”, “Karim”, “Ann”, “Jay”); $count = @persons; Demonstrate: week_four.pl script execution

14 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);

15 Next Lab Assignment # Checks and enforces correct number of arguments (intlist.pl) unless (Fill In Syntax)==(Fill in syntax)){ print "error: incorrect number of arguments", "\n", "usage: intlist a b (where a < b)", "\n"; exit 1; } # Checks that first argument is smaller than second if (Fill In Syntax){ print "error: first argument must be less than second argument", "\n", "usage: intlist a b (where a < b)", "\n"; exit 1; }

16 Next Lab Assignment # prints arguments else { $COUNTER=$(Fill In Syntax); # Sets counter to low integer # Prints integers until high integer is reached while($Fill In Syntax){ print $COUNTER; if ($COUNTER<$(Fill In Syntax)){ print ", "; } else { print "\n"; } $COUNTER(Fill In Syntax)1 } exit 0;

17 Next Lab Assignment # linenum.pl # Handles the enforcement of correct number of arguments unless (Fill In Syntax)==1){ print "error: incorrect number of arguments", "\n", "usage: linenum [filename]", "\n"; exit 1; } # Opens file from argument open((Fill In Syntax), "$(Fill In Syntax)") or die "error: argument must be a file\n", "usage: linenum [filename]\n$!\n";

18 Next Lab Assignment # Checks if file is a directory if (-d "$(Fill In Syntax)"){ print "error: argument must be a file", "\n", "usage: linenum [filename]\n"; exit 1; }

19 Next Lab Assignment $COUNTER=1; # Used for printing line numbers # Writes lines from file while ($LINE=(Fill In Syntax)){ # Adds leading zeros for numbers 1 digit long if ($COUNTER<10){ print “(Fill In Syntax)"; } # Adds leading zeros for numbers 2 digits long if (($COUNTER>9) && ($COUNTER<100)){ print "00"; } # Adds leading zeros for numbers 3 digits long if (($COUNTER>99) && ($COUNTER<1000)){ print "0"; } # Prints line number and line print "$COUNTER: $(Fill In Syntax)"; $COUNTER+=1; } exit 0;

20 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

21 Next Lab Assignment foreach VAR (List) { … } Demonstrate: foreach_global.pl script execution @myNames = ('Larry', 'Curly', 'Moe'); foreach (@myNames) { print $_; } Demonstrate: foreach.pl script execution

22 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.

23 Next lab assignment Demonstrate Execute arry_sort.pl script

24 Next lab assignment Programming Perl text book reading Chapter Three Chapter Four

25 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);

26 Upcoming deadlines Advanced Shell Script, 3-1 is due 9/30/08. Simple Perl Script, 4-1 is due 10/7/08. Mid-term outline to be posted on Bulletin Board by 10/5/08 Mid-term exam date 10/21/08.

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

28


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

Similar presentations


Ads by Google