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 2 - In which of the following variable context, assignment to a scalar variable evaluates the right-hand side in a scalar context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : A

Explanation

Scalar − Assignment to a scalar variable evaluates the right-hand side in a scalar context.

Q 4 - Which of the following function returns true if the named key exists in a Hash?

A - check

B - exists

C - Both of the above.

D - None of the above.

Answer : B

Explanation

exists − exists function, which returns true if the named key exists, irrespective of what its value might be.

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 returns true if the left argument is stringwise equal to the right argument?

A - eq

B - ne

C - cmp

D - ge

Answer : A

Explanation

eq − Returns true if the left argument is stringwise equal to the right argument.

Q 7 - Which of the following operator returns true if the left argument is stringwise not equal to the right argument?

A - eq

B - ne

C - cmp

D - ge

Answer : B

Explanation

ne − Returns true if the left argument is stringwise not equal to the right argument.

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