Perl Scripting Multiple choice Questions

25+ Perl Scripting Multiple choice Questions Answers

Perl Scripting Multiple choice Questions
Perl Scripting Multiple choice Questions

1. When you’re pattern matching, you describe the pattern using:
A. A string in double quotes
B. A MySQL select statement
C. A regular expression
D. A template
Ans: C

2. Perl is:
A. A type of interactive web page
B. A programming language
C. An application program
D. A relational database
Ans: B

3. The printf format “%6.2f” displays a number …
A. At least six columns wide in total, with two figures after the decimal place
B. Exactly six digits before the decimal place, and two digits after
C. At least six digits before the decimal place, and two digits after
D. Exactly six columns wide in total, with two figures after the decimal place
Ans: A

4. The statement open (FH,”abc.txt”);
A. opens the file abc.txt for overwriting
B. opens the file abc.txt for reading
C. contains an error, so won’t compile
D. opens the file abc.txt for appending
Ans: B

5. When you create a variable, you may assume it starts off containing:
A. 1
B. You may not make any assumption
C. The boolean value “false”
D. A null string (or 0 arithmetically)
Ans: D

6. Which brackets do you use to change the order of precedence of operations?
A. Curly braces
B. Square brackets
C. Round brackets
D. You don’t use brackets in Perl – you write in RPN (Reverse Polish Notation)
Ans: C

7. Which of the following tests if the string held in $qn includes the word “perl”?
A. if ($qn =~ /perl/) …..
B. if ($qn == “perl”) ….
C. if ($qn = “perl”) …..
D. if ($qn eq “perl”) …..
Ans: B

8. Which of these is NOT available for Perl:
A. Perl, legally, for free
B. Individual and site licenses
C. Full documentation of the language which you can print out yourself
D. A Carribean cruise in 2006 on which you can meet some of the Perl gurus.
Ans: C

9. Perl was first released in:
A. 1978
B. 1998
C. Perl hasn’t yet been released
D. 1988
Ans: D

10. What will be printed by the code below?
58% on 4261 times asked
my $val = ‘x’;
print ref($val);
A. SCALAR
B. empty value
C. STRING
D. “not a reference”
Ans: B

11. What is a file handle used for?
A. Reading binary data from a file into a scalar variable
B. Finding where a file is on the disc
C. Accessing a disc file or other input/output stream
D. Deleting, moving or renaming a file
Ans: A

12. The “%” operator returns:
A. The larger of two numbers e.g. 200 % 20 would return 200
B. A percentage of a number e.g. 200 % 20 would return 40
C. The remainder when one number is divided by another
D. The remainder when one number is divided by another e.g. 18 % 7 would return 5
Ans: C

13. What is Perl?
A. Practical Extraction and Report Language
B. Practice for Exclusive and Report Language
C. Practical Extraction and Report Learning
D. Practical Exclusive and Report Language
Ans: A

14. Which of the following is used in perl?
A. else if
B. elseif
C. elsif
D. elif
Ans: C

15. The $_ variable
A. holds the last pattern matched.
B. holds the output field separator.
C. identifies the current command line argument.
D. none of the above is correct.
Ans: D

16. The getdir command
A. Reads a single file name from an open directory handle.
B. Reads the rest of the file names from an open directory handle.
C. Only works after anopendir command.
D. Is not a perl command.
Ans: D

17. The value of the expression $yards += 10
A. is 10.
B. is true.
C. cannot be determined from the information given.
D. relies on which command line arguments were used.
Ans: C

18. $x = @y[2 .. 4]
assigns$x the third, fourth and fifth elements of the y array concatenated together.
A. assigns$y[4] to $x.
B. assigns$y[2] to $x.
C. assigns 3 to$x.
Ans: B

19. Which of the following commands will turn a scalar ($str)into an array of characters?
A. @a = split($str).
B. @a = split(/\s/, $str).
C. This task can be done in Perl but none of the above commands do it.
Ans: C

20. <ARGV>
A. more than one of the above is correct.
B. identifies any command line arguments starting with a-.
C. will read the standard input if no arguments are listed on the command line.
D. can be used to read each line in every file name listed on the command line.
Ans: A

21) In Perl, a/n ________ is a special character or a sequence that will define the number of times the previous character or sequence appears.
a) character class
b) metacharacter
c) assertion
d) quantifier
Ans: d

22) In Perl, the following will result in which of the following, if the prize is currently “5 dollars” print ‘You won $prize’;
a) You won $5.00
b) You won 5 dollars
c) You won $prize
d) You won $5
Ans: c

23) In Perl, the words function and subroutines are used interchangeably.
a) True
b) False
Ans: a

24) In Perl, which of the following are file handles?
a) stdquit
b) stdend
c) stdin
d) stdout
e) C&D
Ans: e

25) In Perl, which switch is used for printing out warnings about typographical errors in your script?
a) -P
b) -W
c) -p
d) -w
Ans: d

Frequently Asked Perl Scripting Objective Questions and Answers