Assuming $a = 2, which of the following evaluates as false?
A. "False"
B. $a
C. $a < 0
D. 1
Consider that a file named test.txt contains this line of text: One line of test text.What is the output of the
following lines of code?
$file = "test.txt";
open (OUT, "<$file") || (die "cannot open $file: $!"); seek(OUT, 15, 0);
read(OUT, $buffer, 5);
print $buffer . "\n";
print tell(OUT);
A. t text
B. t tex
C. t text
D. t tex
Consider the following program code:
@stack = (10, 10..25);
push(@stack, yellow);
shift(@stack);
push(@stack, white);
print shift(@stack);
What is the result of executing this program code?
A. The code will fail at line 3 because shift requires two arguments.
B. The code will output the following: 11
C. The code will output the following: 10
D. The code will output the following: white
Which keyword indicates an object reference rather than a variable reference?
A. return
B. bless
C. package
D. object
Which statement will open the /etc/passwd file for reading only?
A. open(PASSFILE "+>/etc/passwd");
B. open(PASSFILE, "/etc/passwd");
C. open(PASSFILE "+
D. open(PASSFILE, ">/etc/passwd");
Running your Perl scripts with a w switch will perform which task?
A. Print all commands to the screen
B. Print warnings to the error.log file
C. Print check points in loops
D. Print warnings to the screen
Consider the following program code:
$x = 10;
LOOP: while ($x < 15)
{
print ($x );
if ($x >= 14 andand $x <= 20)
{
$x += 2;
redo LOOP;
} else { $x++; } } What is the result of executing this program code?
A. The code will output the following: 11 12 13 14 15 16 17 18 19
B. The code will output the following: 10 11 12 13 14 16 18 20 22
C. The code will output the following: 10 11 12 13 14 16 18 20
D. The code will output the following: 10 11 12 13 14 15 16 17 18 19 20
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
Consider the following program code:
$var = 10;
package Alpha;
$var = 20;
{
package Beta;
$var = 30;
}
package Gamma;
$var = 40;
{
print $var;
}
What is the output of this code?
A. 10
B. 20
C. 30
D. 40
Consider the following program code:
$x = 150;
$y = "250";
if (($x + 100) == $y) { print("1 "); }
if ("250" == $y) { print("2 "); }
if ("250" eq $y) { print("3 "); }
if ($x lt $y) { print("4 "); }
if ($x ge $y) { print("5 "); }
What is the result of executing this program code?
A. The code will output the following: 1 2 3 4
B. The code will output the following: 1 3 4
C. The code will output the following: 1 3 5
D. The code will output the following: 1 2 3 4 5
Consider the program code in the attached exhibit.
What is the result of executing this program code?
A. The code will output the following: BOBBY
B. The code will output the following: GERTRUDE
C. The code will output the following: JOHN
D. The code will output the following: ROBERT
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
In Perl, modules are used for which task?
A. To organize packages
B. To provide code reusability
C. To separate code in a file
D. To create separate namespaces
Consider the following program code:
$x = 5;
$y = 10;
while (++$x < 10 andand ++$y < 15)
{
print ($x $y );
}
print ($x $y );
What is the result of executing this program code?
A. The code will output the following: 6 11 7 12 8 13 9 14 10 15
B. The code will output the following: 6 11 7 12 8 13 9 14 10 14
C. The code will output the following: 5 10 6 11 7 12 8 13 9 13
D. The code will output the following: 5 10 6 11 7 12 8 13 9 14
Which statement writes data to the filehandle OUTPUT?
A. print "Here's my data.\n" > OUTPUT
B. write OUTPUT "Here's my data.\n";
C. write OUTPUT ">Here's my data.\n";
D. print OUTPUT "Here's my data.\n";