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 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 sorts the LIST and returns the sorted array value?

A - splice [ SUBROUTINE ] LIST

B - split [ SUBROUTINE ] LIST

C - join [ SUBROUTINE ] LIST

D - sort [ SUBROUTINE ] LIST

Answer : D

Explanation

sort [ SUBROUTINE ] LIST − This function sorts the LIST and returns the sorted array value. If SUBROUTINE is specified then specified logic inside the SUBTROUTINE is applied while sorting the elements.

Q 4 - Which of the following statement restarts the loop block without evaluating the conditional again?

A - next

B - last

C - continue

D - redo

Answer : D

Explanation

redo statement − The redo command restarts the loop block without evaluating the conditional again. The continue block, if any, is not executed.

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

A - while

B - until

C - for

D - None of the above.

Answer : B

Explanation

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

Q 6 - Which of the following operator checks if the value of two operands are equal or not, and returns -1, 0, or 1?

A - ==

B - !=

C - <=>

D - >

Answer : C

Explanation

<=> − Checks if the value of two operands are equal or not, and returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument.

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

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : A

Explanation

q{ } − Encloses a string with-in single quotes.

Q 8 - Which of the following function returns the current local time on the machine that runs the script?

A - localtime

B - gmtime

C - time

D - strftime

Answer : A

Explanation

localtime − returns the current local time on the machine that runs the script.

Q 10 - Which of the following function returns a single character from the specified FILEHANDLE, or STDIN if none is specified?

A - close

B - getc

C - seek

D - None of the above.

Answer : B

Explanation

The getc function returns a single character from the specified FILEHANDLE, or STDIN if none is specified.


perl_questions_answers.htm

Advertisements