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