FREE! Click here to Join FunTrivia. Thousands of games, quizzes, and lots more!
Quiz about Basic Perl Knowledge
Quiz about Basic Perl Knowledge

Basic Perl Knowledge Trivia Quiz


This quiz tests some basic knowledge of Perl. Anyone who's taken an introductory Perl course or read "The Llama" should be able to do well.

A multiple-choice quiz by mritty. Estimated time: 4 mins.
  1. Home
  2. »
  3. Quizzes
  4. »
  5. Science Trivia
  6. »
  7. Computers
  8. »
  9. Software and Programming

Author
mritty
Time
4 mins
Type
Multiple Choice
Quiz #
248,435
Updated
Dec 03 21
# Qns
10
Difficulty
Tough
Avg Score
6 / 10
Plays
477
- -
Question 1 of 10
1. Officially, what does "Perl" stand for? Hint


Question 2 of 10
2. What Perl function will remove a trailing newline from a string, but no other characters? Hint


Question 3 of 10
3. The keywords 'for' and 'foreach' are synonyms, and can be used interchangably.


Question 4 of 10
4. Who is the creator and primary maintainer of Perl? Hint


Question 5 of 10
5. Which of these functions does NOT operate on an array? Hint


Question 6 of 10
6. If @array contains (5, 10, 15), and I assign $x = @array;, then what value is stored in $x? Hint


Question 7 of 10
7. Which of the following is a valid scalar variable name? Hint


Question 8 of 10
8. Which of the following strings would this pattern successfully match: /^[a-z]+_[0-9][0-9]$/ ? Hint


Question 9 of 10
9. If @array contains (5, 10, 15), what does $#array contain? Hint


Question 10 of 10
10. Which of the following keywords are used to define a subroutine in Perl? Hint



(Optional) Create a Free FunTrivia ID to save the points you are about to earn:

arrow Select a User ID:
arrow Choose a Password:
arrow Your Email:




Quiz Answer Key and Fun Facts
1. Officially, what does "Perl" stand for?

Answer: It does not stand for anything

Larry Wall made up the name "Perl" as a single word, not an acronym. Folklore and revisionist history have created expansions like the options listed. For this reason, Perl is *never* to be written in all caps. It is known as a "retronym" or "backronym"
2. What Perl function will remove a trailing newline from a string, but no other characters?

Answer: chomp

chomp() was introduced in Perl 5. Prior to this, only chop() was available. chop() will remove the last character of the string, regardless of what it is.
3. The keywords 'for' and 'foreach' are synonyms, and can be used interchangably.

Answer: True

Even though the two style of loops are known as "for loops" and "foreach loops", you can put "for" anywhere you have "foreach" and vice versa.
foreach ($i = 0 ; $i lt 10 ; $i++) { }
is perfectly valid, as is
for $elem (@array) { }
(*please note that 'lt' above should really be a less-than sign, but the quiz parser seems to think that means it's HTML and won't let me put it there.)
4. Who is the creator and primary maintainer of Perl?

Answer: Larry Wall

Larry Wall created Perl when he decided that none of C, awk, or sed did exactly what he wanted. Perl 1.0 was designed to be the best of all three of those languages.
5. Which of these functions does NOT operate on an array?

Answer: substr

substr() returns and/or modifies a substring of an existing string.
6. If @array contains (5, 10, 15), and I assign $x = @array;, then what value is stored in $x?

Answer: 3

When an array is used in scalar context, it returns its size.
7. Which of the following is a valid scalar variable name?

Answer: $section_32B

Scalar variable names must start with a dollar sign, followed by either a letter or an underscore. The remaining characters may be letters, underscores, or numbers.
8. Which of the following strings would this pattern successfully match: /^[a-z]+_[0-9][0-9]$/ ?

Answer: age_28

The pattern matches: beginning of string, one or more lowercase letters, underscore, two digits, and the end of string.
9. If @array contains (5, 10, 15), what does $#array contain?

Answer: 2

For all arrays, the scalar variable named with the array name with $# replacing the @ contains the last index number of the array. Since arrays are 0-based, the last index is one less than the size.
10. Which of the following keywords are used to define a subroutine in Perl?

Answer: sub

A subroutine is defined by the word 'sub', followed by the subroutine name, an optional prototype, and the subroutine body enclosed in { }
Source: Author mritty

This quiz was reviewed by FunTrivia editor crisw before going online.
Any errors found in FunTrivia content are routinely corrected through our feedback system.
11/21/2024, Copyright 2024 FunTrivia, Inc. - Report an Error / Contact Us