Test your knowledge of Perl with this specially curated set of 30 multiple-choice questions (MCQs). Covering its history, installation, and basic scripting, these questions help you understand core concepts.
MCQs: Chapter 1 – Introduction to Perl
History and Uses of Perl
Who created Perl and in what year? a) Larry Wall, 1987 b) Guido van Rossum, 1991 c) Dennis Ritchie, 1972 d) Bjarne Stroustrup, 1983
Which of the following is a primary use of Perl? a) Web Development b) Text Processing c) System Administration d) All of the above
What does “Perl” stand for? a) Practical Efficient Robust Language b) Portable Environment for Rapid Learning c) Practical Extraction and Report Language d) Performance-Enhanced Regex Language
Which community slogan is associated with Perl? a) “Write once, debug forever.” b) “There’s more than one way to do it.” c) “For every problem, there’s a module.” d) “Code fast, run faster.”
Perl is often referred to as: a) The Glue Language b) The Interpreted Language c) The Language of the Web d) The Scripting Standard
What inspired Larry Wall to create Perl? a) Automating administrative tasks b) Developing a new markup language c) Writing operating systems d) Solving mathematical equations
Perl gained popularity because: a) It was easy to learn b) It had powerful regex support c) It was open-source d) All of the above
Installing Perl and Running Scripts
Which command can check the installed Perl version? a) perl -version b) perl -v c) perl -info d) perl -show
The default package manager for Perl is: a) CPAN b) PIP c) NPM d) Maven
On Windows, Perl can be installed using: a) ActivePerl b) Strawberry Perl c) Both a and b d) None of the above
To execute a Perl script from the terminal, you use: a) perl run script.pl b) perl script.pl c) run script.pl d) execute script.pl
What file extension is typically used for Perl scripts? a) .pl b) .perl c) .script d) .prl
The shebang line at the beginning of a Perl script specifies: a) The output format b) The path to the Perl interpreter c) The script’s version d) Debugging options
How can you install additional Perl modules? a) Using apt-get b) Using CPAN c) Using Yum d) Using PIP
Which command lists all installed modules in Perl? a) perl -modules b) perl -MCPAN -e 'print' c) perldoc -lm d) perl -e "print modules"
Writing Your First Perl Program
What is the correct way to print “Hello, World!” in Perl? a) echo "Hello, World!" b) System.out.println("Hello, World!") c) print "Hello, World!\n"; d) cout << "Hello, World!" << endl;
Perl statements end with: a) A comma b) A semicolon c) A period d) A colon
What is the special variable for input in Perl? a) $_ b) $* c) $$ d) $@
Which operator is used for string concatenation in Perl? a) + b) . c) & d) //
To declare a scalar variable in Perl, you use: a) # b) @ c) % d) $
What keyword is used to define a subroutine in Perl? a) subroutine b) function c) proc d) sub
In Perl, comments start with: a) # b) // c) -- d) /*
Which function is used to get input from the user? a) read() b) print() c) chomp() d) <STDIN>
What does the use strict; pragma enforce? a) Case sensitivity in variable names b) Declaration of variables c) Speed optimization d) Automatic garbage collection
Which function is used to terminate a Perl program? a) exit b) terminate c) end d) stop
What symbol represents an array in Perl? a) $ b) @ c) % d) #
What is the purpose of the chomp function? a) Remove extra spaces b) Remove the newline character c) Convert input to uppercase d) Add a semicolon to input
What is the correct way to use the warn function? a) warn("This is a warning") b) print warn "This is a warning" c) println warn "This is a warning" d) output warn("This is a warning")
What does my do in Perl? a) Declares global variables b) Declares local variables c) Declares constant variables d) Declares environment variables
What is the output of the following code? print “Perl is “, “awesome!”; a) Perl is b) Perl is awesome! c) Perl is, awesome! d) Error: Missing semicolon