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. Common ________: pop(@array) - push(@array, $new Value) - shift(@array) - unshift(@array, $newValue) - sort(@array) - reverse(@array)
(@array)
join(':', @array)
@arrayName size
array functions
2. Stores information about the current users environment. You can print this from the command line using printenv
%ENV hash array
arithmetic comparison operators
lc($string)
Assignment
3. Arrays can be assigned or read in _________
scalar context (Ex: $myArray[4] = 2)
size string comparison operators
Array variables
push(@array, $newValue)
4. Add a new element to the from of the array with the value $newwValue
unshift(@array, $newValue)
lcfirst($string)
execution block
Array variables
5. Split string into an array using spaces as delimeter
Assignment
@arrayName size
split(/\s/, $string)
string manipulation functions
6. The use of ______ in perl - Documenting code - Created by placing a "#" on a line. - are not multi-line
comments
%ENV hash array
flow-control
reverse(%hashName)
7. In arrays elements need not be __________
ucfirst($string)
lc($string)
similar data types
reverse(@array)
8. scalar(@arrayName) returns the ______ of the array names
@arrayName size
use moduleName; Ex: use Roman;
$hashName{keyName}="Value to Add"
(@array)
9. To include modules in perl
use moduleName; Ex: use Roman;
size string comparison operators
Expression Quantifiers
Assignment
10. $#arrayName returns the value of the ______ of the array (NOT the data stored in that array element)
(@array)
last index
newline
$hashName{keyName}="Value to Add"
11. A special system variable used to pass arguments to script
@ARGV
ucfirst($string)
Scalar variables
lc($string)
12. Regular ____________: w - alphanumeric word including underscor - d - digits 0-9 - s any whitespace - . - any character
Expression character classes
interpreter
reverse(%hashName)
basic binding operators
13. Returns all of the values of the hash as an array
values(%hash)
reverse(%hashName)
string manipulation functions
lc($string)
14. _________ in perl - An associative array
Hash variables
delete($hashName{key})
interpreter
chomp(@string)
15. 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
reverse(%hashName)
system() function
flow-control
foreach
16. Common ________: keys(%hash) - values(%hash) - each(%hash) - delete($hash{keyName}) - exists($hash{keyName}) - reverse(%hash)
hash functions
Variable context
$hashName{keyName}="Value to Add"
execution block
17. Modules in perl - Synonymous with header files in C - Collection of ______ and variables that may be used in your program
like functions
chomp($string)
@ARGV
execution block
18. ________ in perl - can be scalar array or hash context - tells the interpreter what you are looking for (Ex: "$arrayname[$index_number]")
flow-control
lc($string)
Variable context
keys(%hash)
19. eq - ne - lt - le - gt - ge
size string comparison operators
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
@ARGV
FILEHANDLE
20. Swap keys for values and values for keys. Will cause issues if there are multiple hash entries with the same value
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
execution block
%ENV hash array
reverse(%hashName)
21. 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
@ARGV
command substitution
basic binding operators
scalar
22. Returns a two element ray of the next key value pair; resultArray[0] is the key resultArray[1] is the value
flow-control
execution block
each(%hash)
@arrayName size
23. Does the hash key with "keyName" exists
(@array)
lc($string)
reverse(@array)
exists($hashName{keyName})
24. To read an entire file into an array (one line per element)
arithmetic comparison operators
@entireFile=<FILEHANDLE>
%ENV hash array
last index
25. _________ in perl - Singular variable - starts with "$" - Number or characer or string- Perl does automatic type conversion of these
Scalar variables
split(/\s/, $string)
Expression character classes
access modes
26. The two phases of creating a PERL program _______ - Execution
Expression Quantifiers
Editing
sort(@array)
(@array)
27. Assignment of hash variables in perl (when oringally defining the hash)
FILEHANDLE
arithmetic comparison operators
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
Hash variables
28. ________ in perl - A collection of data (static data or scalar variables or arrays or hashes can all be stored in an array element)
chomp(@string)
@entireFile=<FILEHANDLE>
sort(@array)
Array variables
29. Join the elements of the array seperating the elements with the ':' character
30. Reverses the elements of the array
size string comparison operators
reverse(@array)
each(%hash)
Hash variables
31. Common ___________: substr($string, $start, $numchars); - length($string) - lc($string) - uc($string) - chomp($string) - chomp(@string) - join(':", @string) - split(/\s/, $string) - lcfirst($string) - ucfirst($string)
system commands
similar data types
string manipulation functions
chomp(@string)
32. Assignment of a hash variable for a single hash element
string manipulation functions
reverse(%hashName)
$hashName{keyName}="Value to Add"
(@array)
33. Explain how to read a line from a file handle
size string comparison operators
uc($string)
$hashName{keyName}="Value to Add"
$line=<FILEHANDLE>
34. < - > - == - <= - >= - !=
Expression character classes
$hashName{keyName}="Value to Add"
arithmetic comparison operators
keys(%hash)
35. The open() statement in perl: open(________, file_mode, "filename.txt")
use moduleName; Ex: use Roman;
FILEHANDLE
length($string)
join(':', @array)
36. Returns a copy of the string as all upper case
reverse(%hashName)
split(/\s/, $string)
uc($string)
sort(@array)
37. Returns all of the keys of the hash as an array
keys(%hash)
size string comparison operators
%ENV hash array
similar data types
38. Sort and array alphabetically
$#arrayName
system() function
split(/\s/, $string)
sort(@array)
39. The variable that provides the last index of an array
$#arrayName
@arrayName size
%ENV hash array
push(@array, $newValue)
40. Regular __________: * - 0 or more characters - + - 1 or more characters - ? - 0 or 1 characters
delete($hashName{key})
Expression Quantifiers
foreach
$line=<FILEHANDLE>
41. Returns a copy of the string with the first letter lower case
scalar context (Ex: $myArray[4] = 2)
lcfirst($string)
delete($hashName{key})
@ARGV
42. Adds a new element to end of the array with value $newValue
newline
push(@array, $newValue)
Expression character classes
command substitution
43. 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
execution block
interpreter
Scalar variables
Editing
44. Delete the hash entry with the key given
FILEHANDLE
length($string)
substr($string, $startindex, $numchars)
delete($hashName{key})
45. Remove trailing newline from each element in the array
join(':', @array)
%ENV hash array
chomp(@string)
unshift(@array, $newValue)
46. The three basic ________ of the open() function: > write - >> append - < read file
chomp(@string)
reverse(@array)
access modes
lcfirst($string)
47. The purpose of {} in an "if" statement: To Define the __________ of the if statement. Unlike C the {} braces ARE REQUIRED
Assignment
execution block
chomp(@string)
each(%hash)
48. Returns the sub string starting at index $startindex and ending after $numchars chars in the string $string
uc($string)
@ARGV
substr($string, $startindex, $numchars)
values(%hash)
49. Two ____________ in regular expressions: =~ Contains - !~ Does not contain
%ENV hash array
last index
array functions
basic binding operators
50. Removes the last element from the array pop
exists($hashName{keyName})
basic binding operators
$hashName{keyName}="Value to Add"
(@array)