Presentation is loading. Please wait.

Presentation is loading. Please wait.

Midterm Review October Closed book one hand written page of notes of your own making October Closed book one hand written page of notes of.

Similar presentations


Presentation on theme: "Midterm Review October Closed book one hand written page of notes of your own making October Closed book one hand written page of notes of."— Presentation transcript:

1 Midterm Review October 23-27 Closed book one hand written page of notes of your own making October 23-27 Closed book one hand written page of notes of your own making

2 Perl Regular Expresions  Extremely Powerful Text Processing.  One of Perls most useful yet most misunderstood features  ‘=~’ indicates a regexp match  if ($var =~ /BLAH/) – Match string  if ($var =~ /^BLAH/) – Start of String  if ($var =~ /BLAH$/) – End of String  if ($var =~ /\w+/) – Any letters  \w - Letters  \d - Numbers  \s - Whitespace . - Anything  Extremely Powerful Text Processing.  One of Perls most useful yet most misunderstood features  ‘=~’ indicates a regexp match  if ($var =~ /BLAH/) – Match string  if ($var =~ /^BLAH/) – Start of String  if ($var =~ /BLAH$/) – End of String  if ($var =~ /\w+/) – Any letters  \w - Letters  \d - Numbers  \s - Whitespace . - Anything

3 Now search for the taxa “hopper” Whoa!! How do I search!!  print "line $_\n";  @words = split /\s+/, $_;  print "$words[0] \n";  print "$words[1] \n";  if($words=~/^hop|^fli/) {  print "found hopper or flick: dna $words[1]\n";  } else {  print "not either";  } Whoa!! How do I search!!  print "line $_\n";  @words = split /\s+/, $_;  print "$words[0] \n";  print "$words[1] \n";  if($words=~/^hop|^fli/) {  print "found hopper or flick: dna $words[1]\n";  } else {  print "not either";  }

4 metacharacters  \ Quote the next metacharacter  ^ Match the beginning of the line . Match any character (except newline)  $ Match the end of the line (or before newline at the end)  | Alternation  () Grouping  [] Character class  By default, the "^" character is guaranteed to match only the beginning of the string, the "$" character only the end (or before the newline at the end), and Perl does certain optimizations with the assumption that the string contains only one line. Embedded newlines will not be matched by "^" or "$". You may, however, wish to treat a string as a multi-line buffer, such that the "^" will match after any newline within the string, and "$" will match before any newline. At the cost of a little more overhead, you can do this by using the /m modifier on the pattern match operator.  \ Quote the next metacharacter  ^ Match the beginning of the line . Match any character (except newline)  $ Match the end of the line (or before newline at the end)  | Alternation  () Grouping  [] Character class  By default, the "^" character is guaranteed to match only the beginning of the string, the "$" character only the end (or before the newline at the end), and Perl does certain optimizations with the assumption that the string contains only one line. Embedded newlines will not be matched by "^" or "$". You may, however, wish to treat a string as a multi-line buffer, such that the "^" will match after any newline within the string, and "$" will match before any newline. At the cost of a little more overhead, you can do this by using the /m modifier on the pattern match operator.

5 quantifiers The following standard quantifiers are recognized: * Match 0 or more times + Match 1 or more times ? Match 1 or 0 times {n} Match exactly n times {n,} Match at least n times {n,m} Match at least n but not more than m times The following standard quantifiers are recognized: * Match 0 or more times + Match 1 or more times ? Match 1 or 0 times {n} Match exactly n times {n,} Match at least n times {n,m} Match at least n but not more than m times

6 Character Class  You can specify a character class, by enclosing a list of characters in "[]", which will match any one character from the list. If the first character after the "[" is "^", the class matches any character not in the list. Within a list, the "-" character specifies a range, so that "a-z" represents all characters between "a" and "z", inclusive.

7 Bracketing  The bracketing construct "(... )" creates capture buffers. To refer to the digit'th buffer use \ within the match. Outside the match use "$" instead of "\".

8 Example $var = "This Midterm"; $var =~ s/^([^ ]*) *([^ ]*)/$2 $1/; $var = "This Midterm"; $var =~ s/^([^ ]*) *([^ ]*)/$2 $1/;

9 Hashes my %ancestors = ( grandfather => "gp", gm => "grandmother", great => "ggf", ); my @mkey = keys %ancestors; my @mval = values %ancestors; print "key ", @mkey[1], ", value ", @mval[2], "\n"; print "gm = ", $ancestors{"gm"}, "\n";

10 Questions What does the listen() command do and how is it related to the connection oriented nature of TCP? Is IP connection oriented? Is Ethernet connection oriented? Is TCP connection oriented? Is HTTP connection oriented? You write() 100 bytes to the client end of a socket. On the server side of the socket you issue a read() for 100 bytes. The read() command returns 20 bytes. Why is this happening?

11 Seven Layer Model Application Presentation Session Transport Network Data Link Physical Network Data Link Physical Network Data Link Physical Application Presentation Session Transport Network Data Link Physical Email, FTP, www cinteger size, big endian synchronization, name space reliability, congestion control Routing address framing errors electrical signals

12 Questions What does the bind() procedure in the socket library do? How does it interact with the TCP and IP layers of the protocol stack. What is a socket? How does a web server use sockets to distinguish between different clients that connect to it?

13 Web Operating System Explain how the web could be the Operating System of the future. In your answer, discuss features traditionally offered by an OS and explain how these could be provided over the web. Scheduling? Service Small requests first? File System? URL Access Control? Security Virtual Memory? Cache Replacement

14 Questions What are the steps a web server must take in processing an HTTP request? What are the differences between the way a web server deals with a GET or POST cgi request. Is HTTP a stateless protocol? What are the 3 ways for a web application to maintain session state? URL Rewriting Hidden Fields Cookies Compare the pros and cons of each method. Explain how an HTTP cookie works. How does a perl application use cookies to create persistant state. What does the SECURE keyword indicate for a cookie?

15 Questions How do signals work with threads and processes? Understand the implementation details and parameters for SysV semaphores. Compare and contrast user level and kernel level threads. What are the differences between threads and processes? What does the fork() system call return? What system call would you use to determine file information? What system call would you use to change the stdout of a process? Why would you want to use a thread pool instead of a single thread for serving requests from browsers? Why would you want to use a thread pool instead of spawning a new thread for each request from a browser? From an Operating Systems perspective, what is the difference between a process and a thread?


Download ppt "Midterm Review October Closed book one hand written page of notes of your own making October Closed book one hand written page of notes of."

Similar presentations


Ads by Google