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

Answer : C

Explanation

Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They are preceded by a percent sign (%).

Q 2 - In which of the following variable context, assignment to an array or a hash evaluates the right-hand side in a list context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : B

Explanation

List − Assignment to an array or a hash evaluates the right-hand side in a list context.

Q 3 - Which of the following method remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified?

A - splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

B - split @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

C - join @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

D - sort @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

Answer : A

Explanation

splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ] - This function will remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified. Finally, it returns the elements removed from the array.

Answer : B

Explanation

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

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 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 returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument?

A - eq

B - ne

C - cmp

D - ge

Answer : C

Explanation

cmp − Returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument.

Answer : A

Explanation

Lexical variables are private variables created using my operator.

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

A - $ref = \$foo;

B - $ref = \@ARGV;

C - $ref = \%ENV;

D - $ref = \&PrintHash;

Answer : C

Explanation

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


perl_questions_answers.htm

Advertisements