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 : C

Explanation

Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They are preceded by a percent sign (%).

Q 2 - In which of the following variable context, assignment to an array or a hash evaluates the right-hand side in a list context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : B

Explanation

List − Assignment to an array or a hash evaluates the right-hand side in a list context.

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.

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

A - keys

B - values

C - Both of the above.

D - None of the above.

Answer : B

Explanation

values − You can get a list of all of the values 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 yes then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : A

Explanation

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

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 increases integer value by one?

A - .

B - x

C - ..

D - ++

Answer : D

Explanation

++ − Auto Increment operator increases integer value by one.

Q 8 - What is the default scope of perl variables?

A - global

B - private

C - protected

D - friend

Answer : A

Explanation

By default, all variables in Perl are global variables, which means they can be accessed from anywhere in the program.

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