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