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