- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Cheatsheet
- Perl - Useful Resources
- Perl - Discussion
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.
Q 1 - Which of the following correctly describes scalar data types in Perl?
A - These are simple variables. They are preceded by a dollar sign ($).
B - These are ordered lists of scalars that you access with a numeric index which starts with 0.
C - These are unordered sets of key/value pairs that you access using the keys as subscripts.
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 an array or a hash evaluates the right-hand side in a list context?
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 joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns the string?
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.
Q 4 - Which of the following statement terminates the loop statement and transfers execution to the statement immediately following the loop?
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 expects the expression to return a label name and then jumps to that labeled statement?
Answer : B
Explanation
goto EXPR − The goto EXPR form is just a generalization of goto LABEL. It expects the expression to return a label name and then jumps to that labeled statement.
Q 6 - Which of the following operator returns true if the left argument is stringwise less than or equal to the right argument?
Answer : C
Explanation
le − Returns true if the left argument is stringwise less than or equal to the right argument.
Answer : A
Explanation
-- − Auto Decrement operator decreases integer value by one.
Q 8 - Which of the following function formats date and time?
Answer : D
Explanation
strftime − formats date and time.
Q 9 - Which of the following function opens a file in writing mode after truncating the file?
Answer : B
Explanation
open(DATA, ">file.txt"); − opens a file in writing mode after truncating the file.
Q 10 - Which of the following code create a reference for a variable?
Answer : A
Explanation
You can create a reference for any variable by prefixing it with a backslash as follows - $ref = \$foo;