Perl Online Quiz


Advertisements

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 type is suppported in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : D

Explanation

All of the above data types are supported in Perl.

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 pops off and returns the last value of the array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : B

Explanation

pop @ARRAY - Pops off and returns the last value of the 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 statement substitutes a call to the named subroutine for the currently running subroutine?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : C

Explanation

goto &NAME − It substitutes a call to the named subroutine for the currently running subroutine.

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

A - <

B - >=

C - <=

D - <=>

Answer : C

Explanation

<= − Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.

Q 7 - Which of the following operator encloses a string with-in invert quotes?

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : C

Explanation

qx{ } − Encloses a string with-in invert quotes.

Q 8 - Parameters of a function can be acessed inside the function using the special array @_?

A - true

B - false

Answer : A

Explanation

Parameters can be acessed inside the function using the special array @_. Thus the first argument to the function is in $_[0], the second is in $_[1], and so on.

Q 9 - Which of the following function opens a file in writing mode after truncating the file?

A - open(DATA, "<file.txt");

B - open(DATA, ">file.txt");

C - open(DATA, "+<file.txt");

D - None of the above.

Answer : B

Explanation

open(DATA, ">file.txt"); − opens a file in writing mode after truncating the file.

Q 10 - Which of the following function returns current position of a pointer in a file?

A - rename

B - tell

C - seek

D - None of the above.

Answer : B

Explanation

You can use tell function to know the current position of a file.

perl_questions_answers.htm
Advertisements