3 Months Free Update
3 Months Free Update
3 Months Free Update
Which of the following choices demonstrates the correct syntax for creating a hash?
Consider the following program code:
$y = 1;
$x = 2;
$z = 3;
do
{
print ($y );
} while ($y eq 2);
do
{
print ($x );
} until ($x eq 2);
print ($z );
What is the result of executing this program code?
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);
Consider the following program code:
$val = 5;
if ($val++ == 6)
{
print("True ");
}
else
{
print("False ");
}
if ($val++ == 6)
{
print("True ");
}
else
{
print("False ");
}
What is the output of this code?
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?
Which one of the following choices will assign the current package Library1?
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?
Consider the following program code:
@array = (10, Masami, 10..13, Niklas);
for ($i = 1; $i < $#array; $i++)
{
print($array[$i] );
}
What is the result of executing this program code?
Which of the following choices demonstrates the correct syntax to pass a reference to a subroutine?
Consider the program code in the attached exhibit. What is the result of executing this program code?
Which of the following choices demonstrates the correct syntax to pass the argument $arg2 to the subroutine getpass?
Consider the following lines of code:
$_ = "This is a test";
s/^([^ ]*)\s*([^ ]*)/$2 $1/;
print;
What is the output of these lines of code?
Which of the following choices demonstrates the correct syntax to pass a reference to a subroutine?
Which one of the following choices will replace all occurrences of the word perl with the word Perl?
Which of the following describes the functionality of the DBI tables method?
Consider the following program code:
$Animal = Dogs bark;
package Cat;
$Animal = Cats purr;
{
package Fish;
$Animal = Fish swim;
}
package main;
print $Animal;
What is the result of executing this program code?
Consider the following program code:
@array = ("ALPHA", "beta", "GaMmA");
@array = sort(@array);
print("@array");
What is the output of this code?
Consider the following program code:
@array = ("ALPHA", "beta", "GaMmA");
sort(@array);
print("@array");
What is the output of this code?
Which of the following tasks is the least effective in reducing errors in Perl scripts?
Consider the following lines of code:
1.$playerStr = "Today's player is Bob Petit.";
2.if($playerStr =~ /[Ruth|Gehrig|DiMaggio]/) {
3. $game = "Baseball";
4.}else{
5. $game = "Basketball";
6.}
7.print $game;
What is the output of these lines of code?
Which one of the following while statements uses correct syntax and expressions?
In the context of Perl user-defined subroutines, which statement is the most accurate?
Which of the following choices demonstrates the correct syntax for creating a hash?
Which one of the following statements uses correct syntax and expressions?
Consider the following program code:
$x = 10;
LOOP: while ($x < 15)
{
print ($x );
if ($x >= 14 && $x <= 20)
{
$x += 2;
redo LOOP;
}
else
{
$x++;
}
}
What is the result of executing this program code?
Consider the following program code:
print(1 );
BEGIN { print(2 ); }
END { print(3 ); }
BEGIN { print(4 ); }
END
{
package MyPackage;
print(5 );
}
What is the result of executing this program code?
Consider the following lines of code:
sub mySub {
$_ = @_[1];
$a = shift;
$b = shift;
return $a * $b * $_;
}
mySub(1,2,3);
What is the output of these lines of code?
Consider the following code:
%hashA = ("alpha", "beta", "gamma", "alpha");
%hashA = reverse(%hashA);
print $hashA{"alpha"};
What is the result of executing this code?
Consider the following lines of code:
1.$playerStr = "Today's player is Bob Petit.";
2.if($playerStr =~ /[Ruth|Gehrig|DiMaggio]/) {
3. $game = "Baseball";
4.}else{
5. $game = "Basketball";
6.}
7.print $game;
What is the output of these lines of code?
Consider the following program code:
@array = ("Y", "W", "X");
@array = sort(@array);
unshift(@array, "Z");
print(@array[0]);
What is the output of this code?
Consider the following program code:
if ("cool" =~ m/[cool]{4}/)
{
print("True ");
}
else
{
print("False ");
}
if ("cool" =~ m/[col]{4}/)
{
print("True ");
}
else
{
print("False ");
}
What is the output of this code?
Consider the following program code:
$i = 15;
LOOP: for(; $i < 25; $i++)
{
if ($i % 2)
{
next LOOP;
}
print($i );
}
What is the result of executing this program code?
Consider the following lines of code:
sub mySub { (
$arg, @args) = @_;
foreach $val (@args) {
$returnVal .= "$arg, $val\n";
}
$returnVal . "" . @args;
}
print &mySub(1, "a value", "another value", "a parameter", "another parameter");
What is the output of these lines of code?
Consider the following command:
perl runme.pl arg1 arg2 arg3
Given this command issued on the command line, what is the value of @ARGV?
Which keyword indicates an object reference rather than a variable reference?