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