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