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