Next: , Up: (dir)

Scripting Languages G22.3033-002 Summer 2008


Previous: Top, Up: Top

Scripting Languages G22.3033-002 Summer 2008 quiz2

Thursday 6/26/2008. 30 points.

http://www.cs.nyu.edu/courses/summer08/G22.3033-002/


Up: quiz2

Quiz 2 problems.


Next: , Up: quiz2-problems

quiz2-1 Regular expressions

(3+3+4 = 10 points) Consider the following Perl regular expression:

     ^[0-9]+(\.[0-9]*)?$
  1. Give two examples of strings matched by the regular expression.
  2. Give two examples of strings for which the regular expression does not match.
  3. Change the regular expression so that it can only start with a 0 if that 0 is the entire part before the decimal point. For example, the string "0.99" should still match, but the string "001.23" should not match.


Next: , Previous: quiz2-1, Up: quiz2-problems

quiz2-2 Server-side scripting

(3+3+4 = 10 points)

  1. Where does the input for a PHP script come from?
  2. Where does the output of a PHP script go to?
  3. What is a self-processing page?


Previous: quiz2-2, Up: quiz2-problems

quiz2-3 Context

(4+2+2+2 = 10 points) Consider the following Perl code:

     @x = (7, 8, 9);
     $y = (7, 8, 9);
     print @x + 0;
     for $i (@x) { print $i }
     for $i ($y) { print $i }
  1. What does the code print?
  2. What is the implicit conversion for using a list literal in a scalar context in Perl?
    How does the above example illustrate this?
  3. What is the implicit conversion for using an array in a scalar context in Perl?
    How does the above example illustrate this?
  4. What is the implicit conversion for using a scalar in a list context in Perl?
    How does the above example illustrate this?