You are on page 1of 3

Perl Test

(No overwriting & crossing is allowed)

1. When you're pattern matching, you describe the pattern using:


• A string in double quotes
• A MySQL select statement
• A regular expression
• A template
2. Perl is:
• A type of interactive web page
• A programming language
• An application program
• A relational database
3. 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
4. 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't compile
• opens the file abc.txt for appending
5. When you create a variable, you may assume it starts off containing:
• 1
• You may not make any assumption
• The boolean value "false"
• A null string (or 0 arithmetically)
6. Which brackets do you use to change the order of precedence of operations?
• Curly braces
• Square brackets
• Round brackets
• You don't use brackets in Perl - you write in RPN (Reverse Polish Notation)
7. Which of the following tests if the string held in $qn includes the word "perl"?

• if ($qn =~ /perl/) .....


• if ($qn == "perl") ....
• if ($qn = "perl") .....
• if ($qn eq "perl") .....
8. 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.
9. Perl was first released in:
• 1978
• 1998
• Perl hasn't yet been released
• 1988
10. Which of the following is NOT a comment line in a Perl program?
• # This is a comment
• #/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/
• ##########################################################
• //////////////////////////////////////////////////////////
11. 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
12. 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
13. What is Perl?
• Practical Extraction and Report Language
• Practice for Exclusive and Report Language
• Practical Extraction and Report Learning \
• Practical Exclusive and Report Language
14. Which of the following is used in perl?
• else if
• elseif
• elsif
• elif
15. The $_ variable
• holds the last pattern matched.
• holds the output field separator.
• identifies the current command line argument.
• none of the above is correct.
16. 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.
17. $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.
18. 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.
• @a = split(/./, $str).

19. In Perl, the words function and subroutines are used interchangeably.
• True
• False

20. 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
***

You might also like