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