CGI Forms   «Prev  Next»

Perl Server CGI - Quiz

Each question is worth one point. Select the best answer for each question.
1. Use this HTTP request to answer the following questions: GET /program.cgi?foo=one&bar=two HTTP/1.1 Host: luna User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Referer: https://luna/advanced-perl/module3/business-order-form.html What object is being requested?
Please select the correct answer:
  A. program.cgi
  B. https://luna/advanced-perl/module3/business-order-form.html
  C. Mozilla/5.0

2. What will be the value of HTTP_USER_AGENT?
Please select the correct answer:
  A. https://luna/advanced-perl/module3/business-order-form.html
  B. (Windows NT 10.0; Win64; x64)
  C. Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

3. What variable will have the value luna?
Please select the correct answer:
  A. HTTP_HOST
  B. User-Agent
  C. HTTP_GET

4. In the same request, which CGI environment variable holds exactly the string foo=one&bar=two?
Please select the correct answer:
  A. PATH_INFO
  B. QUERY_STRING
  C. REQUEST_URI
  D. CONTENT_LENGTH

5. Which statement about the Referer header in a CGI program is correct?
Please select the correct answer:
  A. It becomes HTTP_REFERRER, spelled with a double r
  B. It is always present when the user arrives by clicking a link
  C. It can be checked to confirm that a form was submitted from your own site
  D. It becomes HTTP_REFERER, and may be absent or reduced to the bare origin depending on the browser's referrer policy

6. A CGI script beginning with use CGI; runs on an older server but dies with Can't locate CGI.pm in @INC on a newer one. What is the most likely reason?
Please select the correct answer:
  A. The module was renamed, and the script must now use use CGI::Simple;
  B. CGI.pm was removed from the Perl core distribution in Perl 5.22 and must be installed from CPAN
  C. CGI.pm only loads when the server is running mod_perl
  D. The server has CGI execution disabled, which prevents Perl from loading the module