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