UNIVERSITY OF PORTSMOUTH

 

 

COMPUTING AND MATHEMATICS

 

 

SEMESTER 1 EXAMINATIONS 2001/2002

 

 

LEVEL M

 

 

CN.WPSSM/U05906

 

 

 

WEB PROGRAMMING – SERVER SIDE

 

 

 

Date:                        Monday 4 February 2002

 

Time:                        1.30 – 2.30 pm

 

Duration:                        1 hour

 

 

Instructions:                        Answer ALL of Section A

 

                        Answer ONE question from Section B

 

                        This is an OPEN BOOK Examination

 

 

 


Section A

 

1.      This question is about the Perl programming language.

 

a)      What is the preciseoutput of executing the following Perl code?

 

%table = (name => Jim, age => 21);

foreach $entry (sort keys %table) {
     print "$entry:$table{$entry}:\n";
}

[5 marks]

 

b)      What is the preciseoutput of executing the following Perl code?

 

$text = "Hello World";
$text =~ s/[a-f]/x/g;
print "$text\n";
$text =~ s/\w[xd]*/Y/;
print "$text\n";

[5 marks]

 

 

2.      This question is about invoking scripts from a web server.

 

a)      Explain the difference between the way a web server typically invokes a Perl script and the way it typically invokes a PHP script.

[5 marks]

 

b)      Briefly discuss the pros and cons of each approach described in part (a).

[5 marks]

 

3.      This question is about the way data is passed to a CGI program.

 

a)      Contrast the ways in which the web browser passes data from an HTML form to the web server according to whether the request to the server uses the GET method or the POST method.

[5 marks]

 

b)      Contrast the ways in which the web server passes data to a CGI program according to whether the request to the server uses the GET method or the POST method.

[5 marks]


Section B

 

4.      Imagine you are designing a website with dynamic server-side driven content. Describe and contrast the situations in which you would choose to use the GET and POST methods when implementing an HTML form and explain why. In particular, why is the GET method considered "safe" and POST not?

[20 marks]

 

Looking for an answer that includes several of the following points and shows understanding of the issues surrounding their application. Normal "essay" type marking.

5.      Write a Perl program that reads in lines of text from standard input and prints them out modified as follows:

 

·        any line that begins with a hash (#) is not output

·        any line where the first character is a vowel (a,e,i,o,u) has all its characters reversed

·        all instances of the string "sos" (in upper or lower case) are replaced by the word "help"

·        only the first 20 characters of any output line are printed - any more characters are not output

 

For example, the input

#text

hello world

early birds catch worms

qser2hweoisosqwejwrh

ertwejhrtkjlqwhrtejthlkqwehtlqwhlethwlrqlh

results in

hello world
smrow hctac sdrib yl
qser2hweoihelpqwejwr
hlqrlwhtelhwqlthewqk

 

[20 marks]