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