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