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