Scripting Languages G22.3033-002 Summer 2008
Scripting Languages G22.3033-002 Summer 2008 quiz2
Thursday 6/26/2008. 30 points.
http://www.cs.nyu.edu/courses/summer08/G22.3033-002/
Quiz 2 problems.
quiz2-1 Regular expressions
(3+3+4 = 10 points)
Consider the following Perl regular expression:
^[0-9]+(\.[0-9]*)?$
- Give two examples of strings matched by the regular expression.
- Give two examples of strings for which the regular expression does not
match.
- 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.
quiz2-2 Server-side scripting
(3+3+4 = 10 points)
- Where does the input for a PHP script come from?
- Where does the output of a PHP script go to?
- What is a self-processing page?
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 }
- What does the code print?
- What is the implicit conversion for using a list literal in a scalar
context in Perl?
How does the above example illustrate this?
- What is the implicit conversion for using an array in a
scalar context in Perl?
How does the above example illustrate this?
- What is the implicit conversion for using a scalar in a
list context in Perl?
How does the above example illustrate this?