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

Explanation

Arrays are ordered lists of scalars that you access with a numeric index which starts with 0. They are preceded by an "at" sign (@).

Q 2 - Which of the following data types are preceded by a percent sign (%) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : C

Explanation

Hashes are preceded by a percent sign (%).

Q 3 - Which of the following method joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns the string?

A - splice EXPR, LIST

B - split EXPR, LIST

C - join EXPR, LIST

D - sort EXPR, LIST

Answer : C

Explanation

join EXPR, LIST − This function joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns the string.

Answer : B

Explanation

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

Q 5 - Which of the following statement substitutes a call to the named subroutine for the currently running subroutine?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : C

Explanation

goto &NAME − It substitutes a call to the named subroutine for the currently running subroutine.

Q 6 - Which of the following operator returns true if the left argument is stringwise less than or equal to the right argument?

A - lt

B - gt

C - le

D - ge

Answer : C

Explanation

le − Returns true if the left argument is stringwise less than or equal to the right argument.

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

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : C

Explanation

qx{ } − Encloses a string with-in invert quotes.

Q 8 - Which of the following function returns epoch time?

A - localtime

B - gmtime

C - time

D - strftime

Answer : C

Explanation

time − returns epoch time, i.e. the numbers of seconds that have elapsed since a given date, in Unix is January 1, 1970.

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 function returns a single character from the specified FILEHANDLE, or STDIN if none is specified?

A - close

B - getc

C - seek

D - None of the above.

Answer : B

Explanation

The getc function returns a single character from the specified FILEHANDLE, or STDIN if none is specified.

perl_questions_answers.htm
Advertisements