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