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