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