Perl Online Quiz



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

Answer : A

Explanation

Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number, a string, or a reference. A reference is actually an address of a variable, which we will see in the upcoming chapters.

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 3 - Which of the following method pushes the values of the list onto the end of the array?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : A

Explanation

push @ARRAY, LIST − Pushes the values of the list onto the end of the array.

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 or equal to the value of right operand, if yes then condition becomes true?

A - <

B - >=

C - <=

D - <=>

Answer : B

Explanation

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

Q 7 - Which of the following operator returns a string consisting of the left operand repeated the number of times specified by the right operand?

A - .

B - x

C - ..

D - ++

Answer : B

Explanation

x − The repetition operator x returns a string consisting of the left operand repeated the number of times specified by the right operand.

Answer : A

Explanation

Lexical variables are private variables created using my operator.

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

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : B

Explanation

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

perl_questions_answers.htm
Advertisements