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