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