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