Exam 1: Answers for the multiple choice questions
1) b
2) d
3) c
4) d
5) e
6) d
7) c
8) a
9) b
10) d
11) a
12) e
13) a
14) c
15) a
Exam 3: Answers for the short answer questions
1. 224466
2. It prints the second file.
3. Deletes too much because ".*" is greedy; use ".*?"
4. $phone = param("phone"); print $phone;
5. /^[\w]{6,6}$/
6. PHP: uses templates; single purpose language; Perl: multi-purpose language
7. HTTP_REFERRER
8. using hidden text submitted with the query string
9. vendor-independent, works for all databases
10. Database interfaces; guestbook; greeting card application;
Information stored at remote computer;
Exam 4: Answers for the short answer questions
1. 12888
2. It appends the first line from each file.
3. @fields = split (/<\/td>
/,$line); $row = join (",",@fields);
4. $address = param("address"); print $address;
5. /^\d\d\d \d\d\d\d$/
6. Perl/CGI runs as separate process; mod_perl runs within Apache
7. HTTP_USER_AGENT
8. maintaining state, sessions
9. vendor independence
10. Database interfaces; guestbook; greeting card application; WebCT;
library catalogue
Answers for the User Questions
Note: these questions are real questions that users have asked in Internet
Forums. Real users don't always formulate their questions very well. Sometimes
what they are trying to do is simply not possible and needs to be approached
in a completely different way. To answer these questions, first,
you need to figure out what the real problem is. To do this you need
your knowledge of Perl/PHP but also common sense about programming. Once you
know the answer, you should write it in a way that a user can understand.
Don't worry if the problem is about a programming language that you are not
very familiar with. The problem will be in the logic of the program, not
about code specifics or syntax.
1. This code has probably been used while the programmer debugged the code.
It has no purpose anymore. You can delete that line.
2. CGI/Perl and JSP are two different server-side languages. There is no reason
to use two languages in a single program. You should decide to use either
CGI/Perl or JSP.
3. You can do this by using regular expressions. Do a search for "regular expressions"
and "email" on the web!
4. You are able to match only the last line because your code overwrites
everything else. The problem is that the print statement is outside the
while loop. Thus everything that happens in the while loop is ignored -
apart from the last line.
5. If you have 84 variables of the same type which you want to process in
a FOR statement, you need to put these variables into an array. Look up
how to create arrays in the VBScript documentation!
|