MCQs on Introduction to Perl | Perl

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

  1. Who created Perl and in what year?
    a) Larry Wall, 1987
    b) Guido van Rossum, 1991
    c) Dennis Ritchie, 1972
    d) Bjarne Stroustrup, 1983
  2. Which of the following is a primary use of Perl?
    a) Web Development
    b) Text Processing
    c) System Administration
    d) All of the above
  3. 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
  4. 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.”
  5. Perl is often referred to as:
    a) The Glue Language
    b) The Interpreted Language
    c) The Language of the Web
    d) The Scripting Standard
  6. 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
  7. 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

  1. Which command can check the installed Perl version?
    a) perl -version
    b) perl -v
    c) perl -info
    d) perl -show
  2. The default package manager for Perl is:
    a) CPAN
    b) PIP
    c) NPM
    d) Maven
  3. On Windows, Perl can be installed using:
    a) ActivePerl
    b) Strawberry Perl
    c) Both a and b
    d) None of the above
  4. 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
  5. What file extension is typically used for Perl scripts?
    a) .pl
    b) .perl
    c) .script
    d) .prl
  6. 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
  7. How can you install additional Perl modules?
    a) Using apt-get
    b) Using CPAN
    c) Using Yum
    d) Using PIP
  8. 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

  1. 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;
  2. Perl statements end with:
    a) A comma
    b) A semicolon
    c) A period
    d) A colon
  3. What is the special variable for input in Perl?
    a) $_
    b) $*
    c) $$
    d) $@
  4. Which operator is used for string concatenation in Perl?
    a) +
    b) .
    c) &
    d) //
  5. To declare a scalar variable in Perl, you use:
    a) #
    b) @
    c) %
    d) $
  6. What keyword is used to define a subroutine in Perl?
    a) subroutine
    b) function
    c) proc
    d) sub
  7. In Perl, comments start with:
    a) #
    b) //
    c) --
    d) /*
  8. Which function is used to get input from the user?
    a) read()
    b) print()
    c) chomp()
    d) <STDIN>
  9. What does the use strict; pragma enforce?
    a) Case sensitivity in variable names
    b) Declaration of variables
    c) Speed optimization
    d) Automatic garbage collection
  10. Which function is used to terminate a Perl program?
    a) exit
    b) terminate
    c) end
    d) stop
  11. What symbol represents an array in Perl?
    a) $
    b) @
    c) %
    d) #
  12. 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
  13. 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")
  14. What does my do in Perl?
    a) Declares global variables
    b) Declares local variables
    c) Declares constant variables
    d) Declares environment variables
  15. 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

Answer Key

QnoAnswer
1a) Larry Wall, 1987
2d) All of the above
3c) Practical Extraction and Report Language
4b) “There’s more than one way to do it.”
5a) The Glue Language
6a) Automating administrative tasks
7d) All of the above
8b) perl -v
9a) CPAN
10c) Both a and b
11b) perl script.pl
12a) .pl
13b) The path to the Perl interpreter
14b) Using CPAN
15c) perldoc -lm
16c) print "Hello, World!\n";
17b) A semicolon
18a) $_
19b) .
20d) $
21d) sub
22a) #
23d) <STDIN>
24b) Declaration of variables
25a) exit
26b) @
27b) Remove the newline character
28a) warn("This is a warning")
29b) Declares local variables
30b) Perl is awesome!

			

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top