![Perl Tutorial](/perl/images/perl-mini-logo.jpg)
- Perl Basics
- 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 Advanced
- 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 - 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.
![Questions and Answers](/images/questions_and_answers.png)
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 - Which of the following variable context doesn't care what the return value is?
Answer : D
Explanation
Void − This context not only doesn't care what the return value is, it doesn't even want a return value.
Q 3 - Which of the following method shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down?
Answer : C
Explanation
shift @ARRAY − Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down.
Q 4 - How will you get the size of a Hash?
Answer : A
Explanation
You can get the size − that is, the number of elements from a hash by using the scalar context on either keys or values.
Q 5 - Which of the following statement repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body?
Answer : A
Explanation
while loop − Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
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.
Q 7 - Which of the following operator returns true if the left argument is stringwise not equal to the right argument?
Answer : B
Explanation
ne − Returns true if the left argument is stringwise not equal to the right argument.
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 is true about state variables?
B - These variables are defined using the state operator and available starting from Perl 5.9.4.
Answer : C
Explanation
Both of the above options are correct.
Q 10 - Which of the following code create a reference for a array?
Answer : B
Explanation
You can create a reference for any array by prefixing it with a backslash as follows - $ref = \@ARGV;