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