SUBJECTS
|
BROWSE
|
CAREER CENTER
|
POPULAR
|
JOIN
|
LOGIN
Business Skills
|
Soft Skills
|
Basic Literacy
|
Certifications
About
|
Help
|
Privacy
|
Terms
|
Email
Search
Test your basic knowledge |
Perl Programming
Start Test
Study First
Subject
:
it-skills
Instructions:
Answer 50 questions in 15 minutes.
If you are not ready to take this test, you can
study here
.
Match each statement with the correct term.
Don't refresh. All questions and answers are randomly picked and ordered every time you load a test.
This is a study tool. The 3 wrong answers for each question are randomly chosen from answers to other questions. So, you might find at times the answers obvious, but you will see it re-enforces your understanding as you take the test each time.
1. _________ of scalar variables in perl - using "=" - Ex: $myVariable = 5;
array functions
reverse(@array)
join(':', @array)
Assignment
2. Returns a copy of the string as all upper case
scalar context (Ex: $myArray[4] = 2)
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
Assignment
uc($string)
3. The use of "if" "if-else" and "if-elsif-else"
lc($string)
lcfirst($string)
flow-control
each(%hash)
4. Does the hash key with "keyName" exists
Variable context
$#arrayName
exists($hashName{keyName})
reverse(@array)
5. Split string into an array using spaces as delimeter
ucfirst($string)
split(/\s/, $string)
chomp($string)
reverse(%hashName)
6. A special system variable used to pass arguments to script
%ENV hash array
@ARGV
like functions
scalar context (Ex: $myArray[4] = 2)
7. In perl the _______ will recognize syntax errors and halt execution BEFORE it begins - and will output statements; it does not understand and the line which it encountered the error on
$hashName{keyName}="Value to Add"
reverse(%hashName)
interpreter
chomp($string)
8. The purpose of {} in an "if" statement: To Define the __________ of the if statement. Unlike C the {} braces ARE REQUIRED
execution block
Variable context
values(%hash)
(@array)
9. Adds a new element to end of the array with value $newValue
string manipulation functions
push(@array, $newValue)
lcfirst($string)
Assignment
10. Modules in perl - Synonymous with header files in C - Collection of ______ and variables that may be used in your program
array functions
sort(@array)
interpreter
like functions
11. Removes the last element from the array pop
hash functions
uc($string)
size string comparison operators
(@array)
12. Removes the first element of the array shift
$line=<FILEHANDLE>
Assignment
(@array)
@entireFile=<FILEHANDLE>
13. The two primary methods of executing _______ in perl: - system("command args") - - `command args`
@entireFile=<FILEHANDLE>
split(/\s/, $string)
basic binding operators
system commands
14. The _______ in perl: - used to execute an external command - will output results of command to terminal - returns the exit status of the program that ran - use this for commands that you dont care about SAVING the output to a variable
system() function
uc($string)
ucfirst($string)
flow-control
15. Assignment of a hash variable for a single hash element
Assignment
scalar context (Ex: $myArray[4] = 2)
push(@array, $newValue)
$hashName{keyName}="Value to Add"
16. _________ $#arrayName give value of last index available in the array. Ex an array of size 5 will have its $#arrayName = 4
$hashName{keyName}="Value to Add"
Special array
Variable context
FILEHANDLE
17. Two ____________ in regular expressions: =~ Contains - !~ Does not contain
push(@array, $newValue)
basic binding operators
like functions
chomp($string)
18. The four types of loops in perl: while - until - for - ________
push(@array, $newValue)
reverse(@array)
use moduleName; Ex: use Roman;
foreach
19. Common ___________: substr($string, $start, $numchars); - length($string) - lc($string) - uc($string) - chomp($string) - chomp(@string) - join(':", @string) - split(/\s/, $string) - lcfirst($string) - ucfirst($string)
last index
sort(@array)
string manipulation functions
like functions
20. Assignment of hash variables in perl (when oringally defining the hash)
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
ucfirst($string)
lc($string)
join(':', @array)
21. Reverses the elements of the array
reverse(@array)
scalar context (Ex: $myArray[4] = 2)
array functions
interpreter
22. _________ @arrayName) returns the size of the array
foreach
basic binding operators
push(@array, $newValue)
scalar
23. The __________ in perl: - uses grave marks `command args`- returns the output of the command to the variable you specify - if $output = `command arg` the output is stored all in one variable (all lines seperated by n) - if @output = `command arg` the
keys(%hash)
$#arrayName
command substitution
like functions
24. Regular ____________: w - alphanumeric word including underscor - d - digits 0-9 - s any whitespace - . - any character
length($string)
(@array)
reverse(@array)
Expression character classes
25. _________ in perl - An associative array
join(':', @array)
$#arrayName
Hash variables
Expression character classes
26. Delete the hash entry with the key given
delete($hashName{key})
interpreter
Scalar variables
array functions
27. Returns a two element ray of the next key value pair; resultArray[0] is the key resultArray[1] is the value
last index
lc($string)
Expression Quantifiers
each(%hash)
28. < - > - == - <= - >= - !=
lcfirst($string)
system() function
arithmetic comparison operators
chomp(@string)
29. Returns all of the values of the hash as an array
values(%hash)
Editing
sort(@array)
unshift(@array, $newValue)
30. Returns a copy of the string as all lower case
delete($hashName{key})
like functions
uc($string)
lc($string)
31. eq - ne - lt - le - gt - ge
basic binding operators
Expression Quantifiers
size string comparison operators
%ENV hash array
32. Returns the sub string starting at index $startindex and ending after $numchars chars in the string $string
sort(@array)
like functions
substr($string, $startindex, $numchars)
interpreter
33. Stores information about the current users environment. You can print this from the command line using printenv
%ENV hash array
exists($hashName{keyName})
split(/\s/, $string)
arithmetic comparison operators
34. ________ in perl - A collection of data (static data or scalar variables or arrays or hashes can all be stored in an array element)
reverse(@array)
Array variables
delete($hashName{key})
(@array)
35. ________ in perl - can be scalar array or hash context - tells the interpreter what you are looking for (Ex: "$arrayname[$index_number]")
lcfirst($string)
Variable context
arithmetic comparison operators
hash functions
36. Explain how to read a line from a file handle
each(%hash)
Expression Quantifiers
push(@array, $newValue)
$line=<FILEHANDLE>
37. The variable that provides the last index of an array
$#arrayName
Array variables
Expression character classes
Variable context
38. Remove trailing newline from each element in the array
chomp(@string)
use moduleName; Ex: use Roman;
values(%hash)
reverse(@array)
39. Swap keys for values and values for keys. Will cause issues if there are multiple hash entries with the same value
reverse(%hashName)
ucfirst($string)
Editing
Assignment
40. scalar(@arrayName) returns the ______ of the array names
push(@array, $newValue)
join(':', @array)
@arrayName size
use moduleName; Ex: use Roman;
41. Common ________: keys(%hash) - values(%hash) - each(%hash) - delete($hash{keyName}) - exists($hash{keyName}) - reverse(%hash)
interpreter
Expression character classes
comments
hash functions
42. To read an entire file into an array (one line per element)
each(%hash)
last index
@entireFile=<FILEHANDLE>
interpreter
43. $#arrayName returns the value of the ______ of the array (NOT the data stored in that array element)
interpreter
FILEHANDLE
ucfirst($string)
last index
44. In arrays elements need not be __________
Hash variables
similar data types
keys(%hash)
last index
45. Returns a copy of the string with the first letter lower case
Expression Quantifiers
scalar context (Ex: $myArray[4] = 2)
lcfirst($string)
Scalar variables
46. Join the elements of the array seperating the elements with the ':' character
47. The use of ______ in perl - Documenting code - Created by placing a "#" on a line. - are not multi-line
Expression Quantifiers
comments
last index
hash functions
48. Regular __________: * - 0 or more characters - + - 1 or more characters - ? - 0 or 1 characters
hash functions
Expression Quantifiers
similar data types
newline
49. Returns a copy of the string with the first letter upper case
(@array)
ucfirst($string)
comments
$#arrayName
50. Sort and array alphabetically
like functions
values(%hash)
chomp($string)
sort(@array)