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