CS 290W
Exam 3
May 6, 1999


(1) Why do we say that Perl is a "scripting" language?

(a) Perl programs cannot have any functions.
(b) Perl is not compiled.  It is interpreted at run time. 
(c) Perl is NOT an object-oriented programming language.
(d) Perl programs are used for cgi applications.
(b) 

(2) Suppose that you are working in a company where the Perl
interpreter is named "perlinterp" and is in the directory
/opt/perl/bin.  What should be the first line of all Perl programs?

(a) #!/opt/perl/bin/perlinterp
(b) #!/opt/perl/bin
(c) #!/perlinterp
(d) #!/usr/local/bin/perl
(a) 

(3) You have created a Perl script to be used with a Website.  Which
command should be used to set its file permissions?

(a) chmod a+r search.cgi
(b) chmod a+rw search.cgi
(c) chmod a+rx search.cgi
(d) chmod u+rx search.cgi
(c) 

(4) Which of the following is a Perl integer variable using Hungarian
Notation? 
(a) $total
(b) $iTotal
(c) iTotal
(d) $totalI
(b) 

(5) Suppose that $sAddr contains "Wooly".  What will be in $sHold
after the two statements below:
  $sRem = chop ($sAddr);
  $sHold = $sAddr.$sRem;
(a) "yWool"
(b) "Wool"
(c) "Wooly"
(d) "WoolyWool"
(c) 

(6) What is the only character that the chomp operator will remove?
(a) blank
(b) .
(c) \n
(d) only a digit (0-9)
(c) 

(7) Which of the following correctly tests if one integer is equal to
another? 
(a) ($iMund == $iZobe)
(b) ($iMund eq $iZobe)
(c) ($iMund = $iZobe)
(d) ($iMund.$iZobe)
(a) 

(8) Which of the following inputs a character string from standard input?
(a) $sMuddy = <>;
(b) input ($sMuddy);
(c) STDIN >$sMuddy;
(d) $sMuddy = <STDIN> ;
(d) 

(9) Which of the following is equivalent to 
  while ($iReb <= $iStuv)?
(a) while ($iReb < $iStuv)
(b) until ($iReb > $iStuv)
(c) while ($iReb >= $iStuv)
(d) until ($iReb <= $iStuv)
(b) 

(10) Which of the following creates an array of the lower case letters
from 'a' to 'f'?
(a) $acLetter = ('a'..'f');
(b) @acLetter = ('a','f');
(c) @acLetter = ('a'..'f');
(d) $acLetter = ('a','f');
(c) 

(11) 
  @aiFloor = (35, 43, 78, 54, 22, 11);
  $iSize = @aiFloor;
What is in $iSize?
(a) 5
(b) 6
(c) 11
(d) (35, 43, 78, 54, 22, 11)
(b) 

(12) 
  @aiFloor = (35, 43, 78, 54, 22, 11);
  $iSize = $#aiFloor;
What is in $iSize?
(a) 5
(b) 6
(c) 11
(d) (35, 43, 78, 54, 22, 11)
(a) 

(13) 
  %asElem = ("H", "hydrogen", "O", "oxygen", "C", "carbon");
What is $asElem{"O"}?
(a) 2
(b) 3
(c) "O"
(d) "oxygen"
(d) 

(14) How does an associative array differ from a standard array?
(a) An associative array is indicated by an @ symbol.
(b) In an associative array the items are paired into keys and values.
(c) In a standard array the items are paired into keys and values.
(d) A standard array is indicated by the % symbol.
(b) 

(15) open(TUTORS, ">>tutorlist.txt");
What does the line above mean?
(a) Open the file TUTORS so that new information can be appended at
the end.  Use the file handle tutorlist.txt for it in the perl
program.
(b) Open the file tutorlist.txt so that information can only be read
from it.  Use the file handle TUTORS for it in the perl program. 
(c) Open the file named >>tutorlist.txt for writing.  Use the file
handle TUTORS for it in the perl program. 
(d) Open the file tutorlist.txt so that new information can be
appended at the end.  Use the file handle TUTORS for it in the perl
program. 
(d) 

(16) Which of the following writes to the tutorlist.txt file in the
question above?  (Look carefully!)
(a) print "$sTutorName $sTutorEmail \n";
(b) print tutorlist.txt "$sTutorName $sTutorEmail \n";
(c) print TUTORS "$sTutorName $sTutorEmail \n";
(d) print "TUTORS $sTutorName $sTutorEmail \n";
(c) 

(17) die "Serious problem! \n";
What does the line above mean?
(a) Print the message "Serious problem!" and then stop the program.
(b) Print the message "Serious problem!", but continue with the
program until a terminate command is encountered.
(c) Stop the program immediately.  Do not output the message "Serious 
problem!". 
(d) A file could not be opened.
(a) 

(18) You have a Perl program down in your cgi-bin folder that you want
to call for a form in an HTML file one folder above it.  What should
you use? 
(a) <FORM ACTION="cgi-bin/tootle.cgi" METHOD=POST>
(b) <FORM ACTION="tootle.cgi" METHOD=POST> 
(c) <FORM ACTION="cgi-bin/tootle" METHOD=POST>
(d) <FORM ACTION="cgi-bin/tootle.pl" METHOD=POST>
(a) 

(19) What line of code executes the function:
  sub fRetrieve {...}
(a) $sUmpire = &fRetrieve ($sMulti);
(b) $sUmpire = Retrieve ($sMulti);
(c) &Retrieve;
(d) Retrieve ($sMulti);
(a) 

(20) What statement stops execution of a function and sends back a
value? 
(a) sub
(b) return 
(c) stop
(d) die
(b) 

(21) Which of the following statements in a function will retrieve
the SECOND value sent to the function?
(a) $iWeight = @_;
(b) $iWeight = $_{'2'};
(c) $iWeight = $_[1];
(d) $iWeight = $_[2];
(c) 

(22) Which of the following sends an entire array of strings to the
function fDupl? 
(a) $sFinish = &fDupl ($asMotor);
(b) $sFinish = &fDupl ($asMotor[0]);
(c) $sFinish = &fDupl (@asMotor);
(d) $sFinish = &fDupl ($#asMotor);
(c) 

(23) $sString = "Abraham Lincoln";
     $sSubString = "hamL";
     $iIndex = index($sString, $sSubString); 
What is $iIndex?
(a) 4
(b) 5
(c) 8
(d) -1
(d) 

(24) $sOldString = "Department of Missing Persons"
     $sNewString = substr($sOldString, 14);
What is $sNewString?
(a) "Department of"
(b) "Missing"
(c) " Missing Persons"
(d) "Missing Persons"
(d) 

(25) $sString = "Miller,Melinda";
     $sSubString = ",";
     $iIndex = index($sString, $sSubString); 
     $sNewString = substr($sString, $iIndex +1);
What is $sNewString?
(a) ",Melinda"
(b) "Melinda"
(c) "Miller"
(d) "Miller,"
(b) 

(26) What does the exact opposite of split?
(a) join
(b) unsplit
(c) tr
(d) substr
(a) 

(27) Which SQL command is used to find items in a database?
(a) FIND
(b) SELECT
(c) FETCH
(d) CONNECT
(b) 

(28) Which of the following retrieves only the column Motor from the table
Vehicle for a vehicle with the ID 21745?
(a) SELECT * FROM Vehicle WHERE VehID = 21745;
(b) SELECT Motor FROM Vehicle;
(c) SELECT Motor FROM Vehicle WHERE VehID = 21745;
(d) SELECT VehID = 21745 FROM Vehicle;
(c) 

(29) Which of the following retrieves all the columns from the table
Vehicle for vehicle IDs greater than 30000?
(a) SELECT * FROM Vehicle WHERE VehID > 30000;
(b) SELECT Motor FROM Vehicle WHERE VehID > 30000;
(c) SELECT * WHERE VehID > 30000;
(d) SELECT VehID > 30000;
(a) 

(30) Which of the following retrieves the desired columns only if the
Description contains the string "mud" in it anywhere?
(a) SELECT Milk, Chocolate FROM Snacks WHERE Description LIKE 'mud';
(b) SELECT Milk, Chocolate FROM Snacks WHERE Description LIKE '%mud%';
(c) SELECT Milk, Chocolate FROM Snacks WHERE Description LIKE 'mud%';
(d) SELECT Milk, Chocolate FROM Snacks WHERE Description LIKE '%mud';
(b) 

(31) What line in our Perl scripts made the Oracle functions available?
(a) do "cgi-lib.pl";
(b) use Oraperl;
(c) use Oracle;
(d) use /opt/oracle/product/8.0.4;
(b) 

(32) Which function presents the SQL command to the database?
(a) &ora_login
(b) &ora_select
(c) &ora_fetch
(d) &ora_open
(d) 

(33) Where does &ora_open get the handle that it uses?
(a) &ora_fetch
(b) &ora_login
(c) &ora_handle
(d) &ora_close
(b) 

(34) What does &ora_fetch return to the Perl program?
(a) data from a column of a table
(b) data from a row of a table
(c) data from a cell of a table
(d) all data from the entire table
(b) 

(35) 
$_ = "purdue university";
tr/aeiou/()!+/; 
What is $_ after the tr statement?
(a) "p+rd+) +n!v)rs!ty"
(b) "prd) n!v)rs!ty"
(c) "p rd )  n!v)rs!ty"
(d) "purdu) un!v)rs!ty"
(a) 

(36) 
$_ = "purdue university";
$iHuh = tr/red/zzz/; 
What is $iHuh after the tr statement?
(a) "puzzuz univzzsity"
(b) "puzuz univzsity"
(c) "puu univsity"
(d) 5
(d) 

(37)
$_ = "purdue university";
$iHuh = tr/d-i/p-u/;
What is $_ after the tr statement?
(a) "purpqrstuversity"
(b) "purdue university"
(c) "purpue unuversuty"
(d) "purpuq unuvqrsuty"
(d) 

(38) 
$_ = "purdue university";
$iHuh = tr/aeiouy//d;
What is $_ after the tr statement?
(a) "pdrddd dndvdrsdtd"
(b) "p rd    n v rs t "
(c) "prd nvrst"
(d) "purdue university"
(c) 

(39) 
$_ = "purdue university";
tr/uer/???/s; 
What is $_ after the tr statement?
(a) "p?d? ?niv?sity"
(b) "p??d?? ?niv??sity"
(c) "pdnivsity"
(d) "purdue university"
(a) 

(40) 
$_ = "purdue university";
s/due/abc/; 
What is $_ after the s statement?
(a) "purabc university"
(b) "pbrabc bnivcrsity"
(c) "purdueabc university"
(d) "purdue university"
(a) 

(41) 
$_ = "purdue university";
s/u./12/g; 
What is $_ after the s statement?
(a) "p12d12 12iversity"
(b) "p1rd1e 1niversity"
(c) "purdue university"
(d) "pu12du12 u12iversity"
(a) 

(42) 
$sMovie = "Hello Young People";
$sWord = "you";
Which of the following if statements will be true?
(a) if ($sMovie =~ /$sWord/i)
(b) if ($sMovie =~ /\b$sWord/)
(c) if ($sMovie eq $sWord)
(d) if ($sMovie == $sWord)
(a) 

(43) Which of the following may be tested to determine if a FORM has used the
GET or POST method?
(a) $ENV[0]
(b) $ENV {'QUERY_STRING'}
(c) $ENV {'REQUEST_METHOD'}
(d) $REQUEST_METHOD {'ENV'}
(c) 

(44) Suppose that you have available the parsing program cgi-lib.pl.
What function must you call in order to access FORM data?
(a) cgi-lib
(b) $in
(c) Oraperl
(d) ReadParse
(d) 

(45) 
<INPUT TYPE=RADIO NAME=country VALUE=mexico> Mexico <BR>
<INPUT TYPE=RADIO NAME=country VALUE=canada> Canada <BR>
<INPUT TYPE=RADIO NAME=country VALUE=puerto> Puerto Rico <BR>
Which of the following will test if Puerto Rico is selected?
(a) if ($in{'country'} eq "Puerto Rico")
(b) if ($in{'country'} eq "Puerto+Rico")
(c) if ($in{'country'} eq "puerto")
(d) if ($in{'puerto'} eq "country")
(c) 

(46) 
<INPUT TYPE=CHECKBOX NAME=reply VALUE=sure> dinner <BR>
What value will $in{'reply'} be if this box is checked?
(a) "dinner"
(b) "sure"
(c) "reply"
(d) "CHECKBOX"
(b) 

(47) 
<SELECT NAME=year SIZE=1>
<OPTION CHECKED>Freshman</OPTION>
<OPTION>Sophomore</OPTION>
<OPTION>Junior</OPTION>
<OPTION>Senior</OPTION>
</SELECT>
How can you test if "Junior" is selected?
(a) if ($in{'Junior'} eq "CHECKED")
(b) if ($in{'Junior'} eq "year")
(c) if ($in{'year'} eq "2")
(d) if ($in{'year'} eq "Junior")
(d) 

(48) In the .htaccess file what does "Order deny,allow" mean?
(a) Honor all "deny" lines.  Ignore all "allow" lines.
(b) Deny all access to the Web pages except as specified in the
"allow" lines.
(c) Process all "deny" lines first and then use the "allow" lines as
exceptions. 
(d) Process all "allow" lines first and then use the "deny" lines as
exceptions. 
(c) 

(49) What is the usual name of the file that contains accounts and
passwords for determining Website accessibility?
(a) ht.password
(b) .htgroup
(c) .htaccess
(d) .htpasswd
(d) 

(50) What does the file extension .shtml usually denote?
(a) a file containing cascading Style sheets
(b) a file containing Standard HTML
(c) a file containing Secure HTML
(d) a file containing Server Side Includes
(d) 


Any questions please contact:Becky Koutsis