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 special variable represents current package name?

A - _PACKAGE_

B - Package

C - PACKAGE

D - None of the above.

Answer : A

Explanation

_PACKAGE_ -represents current package name.

Q 3 - Which of the following method prepends list to the front of the array, and returns the number of elements in the new array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : D

Explanation

unshift @ARRAY, LIST - Prepends list to the front of the array, and returns the number of elements in the new array.

Answer : B

Explanation

To remove an element from the hash you need to use delete 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 returns true if the left argument is stringwise greater than the right argument?

A - lt

B - gt

C - le

D - ge

Answer : B

Explanation

gt − Returns true if the left argument is stringwise greater than the right argument.

Q 7 - Which of the following operator decreases integer value by one?

A - --

B - ->

C - ..

D - ++

Answer : A

Explanation

-- − Auto Decrement operator decreases integer value by one.

Answer : C

Explanation

The my operator confines a variable to a particular region of code in which it can be used and accessed. Outside that region, this variable cannot be used or accessed.

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