Olete.in
Articles
Mock Tests
🧪 Perl MCQ Quiz Hub
Perl Mcq Question Set 2
Choose a topic to test your knowledge and improve your Perl skills
1. For looping in a list, ____ is used.
for
fordo
foreach
while
2. perl also supports use of for loop in the following manner. for($i=0;$i<3;$i++){ }
True
False
all of the above
none of the above
3. For splitting a line or expression into fields, __ is used.
foreach
for
split
join
4. ___ function is used for joining lists.
foreach
for
split
join
5. perl is ____ of grep, tr, sed and awk.
subset
superset
child
parent
6. The following will display : perl -e ‘print “UNIX” x 10 . “ ” ;’
UNIX
UNIX 10 times
error message
7. Perl scripts are text files.
True
False
all of the above
none of the above
8. The shebang line is _______
#!
!#
#$
$#
9. When you're pattern matching, you describe the pattern using:
A string in double quotes
A MySQL select statement
A regular expression
A template
10. Perl is:
A type of interactive web page
A programming language
An application program
A relational database
11. The printf format "%6.2f" displays a number …
At least six columns wide in total, with two figures after the decimal place
Exactly six digits before the decimal place, and two digits after
At least six digits before the decimal place, and two digits after
Exactly six columns wide in total, with two figures after the decimal place
12. The statement open (FH,"abc.txt");
opens the file abc.txt for overwriting
opens the file abc.txt for reading
contains an error, so won&#039;t compile
opens the file abc.txt for appending
13. When you create a variable, you may assume it starts off containing:
1
You may not make any assumption
The boolean value &quot;false&quot;
A null string (or 0 arithmetically)
14. Which brackets do you use to change the order of precedence of operations?
Curly braces
Square brackets
Round brackets
You don&#039;t use brackets in Perl - you write in RPN (Reverse Polish Notation)
15. Which of the following tests if the string held in $qn includes the word "perl"?
if ($qn =~ /perl/) .....
if ($qn == &quot;perl&quot;) ....
if ($qn = &quot;perl&quot;) .....
if ($qn eq &quot;perl&quot;) .....
16. Which of these is NOT available for Perl:
Perl, legally, for free
Individual and site licenses
Full documentation of the language which you can print out yourself
A Carribean cruise in 2006 on which you can meet some of the Perl gurus.
17. Perl was first released in:
1978
1998
Perl hasn&#039;t yet been released
1988
18. What will be printed by the code below? 58% on 4261 times asked my $val = 'x'; print ref($val);
SCALAR
empty value
STRING
&quot;not a reference&quot;
19. What is a file handle used for?
Reading binary data from a file into a scalar variable
Finding where a file is on the disc
Accessing a disc file or other input/output stream
Deleting, moving or renaming a file
20. The "%" operator returns:
The larger of two numbers e.g. 200 % 20 would return 200
A percentage of a number e.g. 200 % 20 would return 40
The remainder when one number is divided by another
The remainder when one number is divided by another e.g. 18 % 7 would return 5
21. What is Perl?
Practical Extraction and Report Language
Practice for Exclusive and Report Language
Practical Extraction and Report Learning
Practical Exclusive and Report Language
22. . The $_ variable
holds the last pattern matched.
holds the output field separator.
identifies the current command line argument.
none of the above is correct.
23. The value of the expression $yards += 10
is 10.
is true.
cannot be determined from the information given.
relies on which command line arguments were used.
24. $x = @y[2 .. 4] assigns$x the third, fourth and fifth elements of the y array concatenated together.
assigns$y[4] to $x.
assigns$y[2] to $x.
assigns 3 to$x.
@a = split(/s/, $str).
25. Which of the following commands will turn a scalar ($str)into an array of characters?
@a = split($str).
@a = split(/s/, $str).
This task can be done in Perl but none of the above commands do it.
assigns 3 to$x.
26. <ARGV>
more than one of the above is correct.
identifies any command line arguments starting with a-.
will read the standard input if no arguments are listed on the command line.
can be used to read each line in every file name listed on the command line.
27. In Perl, a/n ________ is a special character or a sequence that will define the number of times the previous character or sequence appears.
character class
metacharacter
assertion
quantifier
28. In Perl, the following will result in which of the following, if the prize is currently "5 dollars" print 'You won $prize';
You won $5.00
You won 5 dollars
You won $prize
You won $5
29. In Perl, which of the following are file handles?
stdquit
stdend
stdin
stdout
30. In Perl, which switch is used for printing out warnings about typographical errors in your script?
-P
-W
-p
-w
31. In Perl, "stat" returns a thirteen element array with which of the following values?
Perl version ID
Web server ID
Last access
Inode number
32. CGI is a programming language.
True
False
all of the above
none of the above
33. In Perl, scalar variables always begin with a ________ sign.
#
@
%
$
34. What will be printed by the code below? my $val = {}; print ref($val);
empty value
ARRAY
HASH
Scalar
35. . What will be printed by the code below? my @a = (0, 1, 2); my $b = @a; print $b;
0
1
2
3
36. What output will be generated by this statement: print("Hello world This is Perl ");?
Hello world This is Perl
Hello world This is Perl
Hello World This is Perl
Hello world This is Perl
37. What is the result of this script: $a = "This is Perl"; $b="This is Perl "; chomp($a); chomp($b);?
$a contains &quot;This is Perl&quot;; $b contains &quot;This is Perl &quot;
$a contains &quot;This is Per&quot;; $b contains &quot;This is Perl &quot;
$a contains &quot;This is Perl&quot;; $b contains &quot;This is Perl&quot;
$a contains &quot;This is Perl &quot;; $b contains &quot;This is Perl &quot;
38. What will be the value in the variable $a after these two statements: $a = "Hello"; $a = "world";?
&quot;Hello world&quot;
&quot;Helloworld&quot;
&quot;Hello&quot;
&quot;world&quot;
39. I want to write an appointment manager program for Microsoft Windows users. It must have a GUI, it must be very fast, and it depends on special GUI features found on only Microsoft Windows. What is the best language for the job?
Perl
Java
C++
Java, Perl, and C++ are equally good for the job.
40. There is another popular scripting language called Python. Like Perl, it reads and runs scripts in one step instead of compiling them ahead of time. What would I need on my computer to use Python?
A Python compiler
A Python editor
A Python virtual machine
A Python interpreter
41. Who designed and developed Perl?
Larry Wall
Guido van Rossum
Ross Ihaka
Martin Odersky
42. Which are the permitted file extensions of perl?
.pl,.p
.t,.p
.pl, .pm
.pl,.perl
43. PONIE is an acronym for?
Perl Of New Information Engine
Perl Of Next Information Engineering
Perl On Next Internal Engine
Perl On New Internal Engine
44. Which symbol is owned by the Perl Foundation?
Elephant
Onion
Parrot
Turnip
45. Which among the following statements are true with respect to Perl? S1: Perl is procedural in nature S2: Perl do automatic data-typing S3: All variables are marked with leading sigils
S1 and S2
S2 and S3
S1 and S3
S1,S2 and S3
46. Which keyword can be used instead of print to have the carriage return added automatically? (v5.10 or higher)
println
$print
say
out
47. Which option can be used to use perl on the command line?
$ perl -e
$ perl -i
$ perl -p
$ perl -r
48. How are single-line commented in Perl?
! Comment goes here
&lt;-- Comment goes here --&gt;
# Comment goes here
// Comment goes here
49. How are multi-line commented in Perl?
!
=
/*
#
50. Which statement enables Plain Old Documentation?
=cut
=doc
=pod
=end
Submit