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