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 file name?

A - FILE

B - _FILE_

C - file

D - None of the above.

Answer : B

Explanation

_FILE_ -represents current file name.

Q 4 - Which of the following statement terminates the loop statement and transfers execution to the statement immediately following the loop?

A - next

B - last

C - continue

D - redo

Answer : B

Explanation

last statement − Terminates the loop statement and transfers execution to the statement immediately following the loop.

Q 5 - Which of the following statement jumps to the statement labeled with LABEL and resumes execution from there?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : A

Explanation

goto LABEL − The goto LABEL form jumps to the statement labeled with LABEL and resumes execution from there.

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

A - ==

B - !=

C - <=>

D - >

Answer : D

Explanation

> − Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

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

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : B

Explanation

qq{ } − Encloses a string with-in double 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 9 - Which of the following function opens a file in read-only mode?

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

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

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

D - None of the above.

Answer : A

Explanation

open(DATA, "<file.txt"); − opens a file in read-only mode.

Q 10 - Which of the following code create a reference for a variable?

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : A

Explanation

You can create a reference for any variable by prefixing it with a backslash as follows - $ref = \$foo;


perl_questions_answers.htm

Advertisements