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

Q 1 - Which of the following data types are preceded by a dollar sign ($) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : A

Explanation

Scalars are preceded by a dollar sign ($).

Q 2 - Which of the following variable context only happens inside quotes, or things that work like quotes?

A - Interpolative

B - List

C - Boolean

D - Void.

Answer : A

Explanation

Interpolative − This context only happens inside quotes, or things that work like quotes.

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.

Q 4 - Which of the following function returns all keys of a Hash?

A - keys

B - values

C - Both of the above.

D - None of the above.

Answer : A

Explanation

keys − You can get a list of all of the keys from a hash by using keys function.

Q 5 - Which of the following operator checks if the value of two operands are equal or not, if values are not equal then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : B

Explanation

!= − Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

Q 6 - Which of the following operator checks if the value of left operand is less than the value of right operand, if yes then condition becomes true?

A - <

B - >=

C - <=

D - <=>

Answer : A

Explanation

> − Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.

Q 7 - Which of the following operator returns a list of values counting (up by ones) from the left value to the right value?

A - .

B - x

C - ..

D - ++

Answer : C

Explanation

.. − The range operator .. returns a list of values counting (up by ones) from the left value to the right value.

Q 8 - How will you get the count of parameters passed to a perl subroutine?

A - Using args

B - using scalar(@_)

C - Both of the above.

D - None of the above.

Answer : B

Explanation

using scalar(@_), we can get the total number of arguments passed.

Q 9 - Which of the following function deletes a file?

A - delete

B - unlink

C - seek

D - None of the above.

Answer : B

Explanation

unlink − used to delete a file.

Q 10 - Which of the following function disassociate the filehandle from the corresponding file?

A - close

B - unlink

C - seek

D - None of the above.

Answer : A

Explanation

close − To close a filehandle, and therefore disassociate the filehandle from the corresponding file, you use the close function. This flushes the filehandle's buffers and closes the system's file descriptor.

perl_questions_answers.htm
Advertisements