Which line of code represents the correct syntax to establish a reference to a database handle?
A. $dbh = DBI::connect("dbi:mysql:myPhoneBook");
B. $dbh = DBD:->connect("dbi::mysql::myPhoneBook");
C. $dbh = DBD::connect("mysql:dbi:myPhoneBook");
D. $dbh = DBI->connect("dbi:mysql:myPhoneBook");
Which statement is the most accurate?
A. The push function adds elements to the beginning of an array.
B. The push function removes the first element in an array.
C. The pop function removes the first element in an array.
D. The pop function removes the last element in an array.
Consider the following program code:
package Dog;
$string = Walk the dog.;
if($string eq Walk the dog.)
{
package Cat;
$string = Pet the cat.;
print($string\n);
}
print ($string\n);
What is the result of executing this program code?
A. The code will output the following: Pet the cat.
B. The code will output the following: Walk the dog.
C. The code will output the following: Pet the cat. Walk the dog.
D. The code will output the following: Walk the dog. Pet the cat.
Consider the following lines of code:
sub mySub { (
$arg, @args) = @_;
foreach $val (@args) {
$returnVal .= "$arg, $val\n";
}
$returnVal . "" . @args;
}
print andmySub(1, "a value", "another value", "a parameter", "another parameter"); What is the output of
these lines of code?
A. 1, a value 1, another value 1, a parameter 1, another parameter 4
B. 1, a value 1, another value 1, a parameter 1, another parameter a valueanother valuea parameteranother parameter
C. 1, a value, another value, a parameter, another parameter a value another value a parameter another parameter
D. 1, a value, another value, a parameter, another parameter 4
Which one of the following statements uses correct syntax and expressions?
A. do (print "Hello $a") until ($a = 10);
B. do {$a++} until {$a == $b}\;
C. do {$in = $in++} while ($in < 100);
D. do ($a++) until ($b = $a);
Which one of the following choices uses the correct syntax for a valid array assignment?
A. @cities = Akron, Memphis, Ogden, Phoenix;
B. @cities =~ ("Akron, Memphis");
C. @cities =~ (Akron, Memphis, Ogden, Phoenix);
D. @cities = ("Akron");
Which one of the following statements opens a file for appending?
A. open(PASSWD, ">/etc/passwd");
B. open(PASSWD ">/etc/passwd");
C. open(PASSWD, ">>/etc/passwd");
D. open(PASSWD "+>/etc/passwd");
Running your Perl scripts with a d switch will perform which task?
A. Invoke the Perl debugger
B. Send standard error to a file
C. Disable breakpoints
D. Display a stack trace
Which of the following choices demonstrates the correct syntax to pass the argument $arg2 to the subroutine getpass?
A. getpass($arg2);
B. call andgetpass($arg2);
C. sub andgetpass($arg2);
D. call getpass($arg2);
Consider the following code block:
BEGIN {print ("Jan ");}
BEGIN {print ("Feb ");}
END {print ("Mar ");}
END {print ("Apr ");} Print ("May ");
What is the result of this code block?
A. Jan Feb May Apr Mar
B. Jan Feb Mar Apr May
C. Mar Apr May Jan Feb
D. May Jan Feb Mar Apr