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