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 an "at" sign (@) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : B

Explanation

Arrays are preceded by an "at" 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.

Answer : B

Explanation

split [ PATTERN [ , EXPR [ , LIMIT ] ] ] - This function splits a string into an array of strings, and returns it. If LIMIT is specified, splits into at most that number of fields. If PATTERN is omitted, splits on whitespace.

Answer : B

Explanation

To remove an element from the hash you need to use delete function.

Q 5 - Which of the following statement executes a sequence of statements multiple times and abbreviates the code that manages the loop variable?

A - while

B - until

C - for

D - None of the above.

Answer : C

Explanation

for loop − Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.

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 concatenates two strings?

A - .

B - x

C - ..

D - ++

Answer : A

Explanation

. − Binary operator dot (.) concatenates two strings.

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 points current position of a pointer to a particular position in a file?

A - rename

B - tell

C - seek

D - None of the above.

Answer : C

Explanation

You can use seek function to point a particular position inside the file.


perl_questions_answers.htm

Advertisements