Perl Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to Perl. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : A

Explanation

Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which we will see in the upcoming chapters.

Q 2 - Which of the following variable context doesn't care what the return value is?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : D

Explanation

Void − This context not only doesn't care what the return value is, it doesn't even want a return value.

Q 3 - Which of the following method shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : C

Explanation

shift @ARRAY − Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down.

Answer : A

Explanation

You can get the size − that is, the number of elements from a hash by using the scalar context on either keys or values.

Q 5 - Which of the following statement repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body?

A - while

B - until

C - for

D - None of the above.

Answer : A

Explanation

while loop − Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.

Q 6 - Which of the following operator returns true if the left argument is stringwise less than or equal to the right argument?

A - lt

B - gt

C - le

D - ge

Answer : C

Explanation

le − Returns true if the left argument is stringwise less than or equal to the right argument.

Q 7 - Which of the following operator returns true if the left argument is stringwise not equal to the right argument?

A - eq

B - ne

C - cmp

D - ge

Answer : B

Explanation

ne − Returns true if the left argument is stringwise not equal to the right argument.

Q 8 - Which of the following function formats date and time?

A - localtime

B - gmtime

C - time

D - strftime

Answer : D

Explanation

strftime − formats date and time.

Q 10 - Which of the following code create a reference for a array?

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : B

Explanation

You can create a reference for any array by prefixing it with a backslash as follows - $ref = \@ARGV;

perl_questions_answers.htm
Advertisements