CS 460 -- A Perl of a Test 1) What does this program do? print "Status: 200 OK\nContent-type: text/html\n\n"; print "A Page about Cookies
\n"; print "Set-Cookie: foo=bar; path=/students; expires Mon, 09-Dec-2002 13:46:00 GMT" 2) If someone sets the cookie as shown below. Which CGI programs can access the cookie? Which hosts and which cgi programs? "Set-Cookie: foo=bar; path=/students; expires Mon, 09-Dec-2008 13:46:00 GMT" 3) Write me perl code that drops the table "Hostess" from the database "Food". 4) Write me a perl program that counts the number of lines in the file "chip"? 5) What does this code do? (Hint: this might be tricky) print foo(3); sub foo { $a = shift; if ($a == 1) { return 1; } else { $a * foo($a-1) } } 6) What is the minimum number of shift's the method must do to read the last argument to the call below? $object->method(1,2,3); 7) Which of the input strings below is matched by the regular expression /^ab*.*a$/ aa aba abba abababa abababab 8) Write me a function in perl that returns the sum of it's two arguments. 9) What does this program print? ===== File: Main.pl ===== #!/usr/bin/perl use IT; it = IT->new(); $y = 2; it->a(3); it->b(5); =====File: it.pm ===== package IT; sub new { my($class) = shift; bless { $x => 0 }, $class; } sub a { my($self) = shift; $y = 12; $self->{"x"} = 17; } sub b { my($self) = shift; print $self->{"x"} . " = $y\n"; }