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
foreach
length($string)
exists($hashName{keyName})
Assignment
2. _________ of scalar variables in perl - using "=" - Ex: $myVariable = 5;
Variable context
lc($string)
last index
Assignment
3. The two phases of creating a PERL program _______ - Execution
scalar
Editing
Hash variables
lc($string)
4. The variable that provides the last index of an array
$#arrayName
FILEHANDLE
@arrayName size
Expression Quantifiers
5. $#arrayName returns the value of the ______ of the array (NOT the data stored in that array element)
interpreter
Array variables
last index
flow-control
6. Returns all of the values of the hash as an array
@arrayName size
values(%hash)
reverse(@array)
FILEHANDLE
7. Does the hash key with "keyName" exists
(@array)
lc($string)
chomp(@string)
exists($hashName{keyName})
8. The open() statement in perl: open(________, file_mode, "filename.txt")
system commands
Scalar variables
size string comparison operators
FILEHANDLE
9. Reverses the elements of the array
reverse(@array)
$hashName{keyName}="Value to Add"
lc($string)
Special array
10. In arrays elements need not be __________
(@array)
Editing
sort(@array)
similar data types
11. Returns a two element ray of the next key value pair; resultArray[0] is the key resultArray[1] is the value
similar data types
keys(%hash)
access modes
each(%hash)
12. The purpose of {} in an "if" statement: To Define the __________ of the if statement. Unlike C the {} braces ARE REQUIRED
execution block
@entireFile=<FILEHANDLE>
use moduleName; Ex: use Roman;
FILEHANDLE
13. Returns the sub string starting at index $startindex and ending after $numchars chars in the string $string
Special array
substr($string, $startindex, $numchars)
%ENV hash array
scalar context (Ex: $myArray[4] = 2)
14. Sort and array alphabetically
newline
print(FILEHANDLE "Data to outputn");
split(/\s/, $string)
sort(@array)
15. < - > - == - <= - >= - !=
arithmetic comparison operators
unshift(@array, $newValue)
chomp($string)
Editing
16. Explain how to read a line from a file handle
$line=<FILEHANDLE>
split(/\s/, $string)
reverse(%hashName)
delete($hashName{key})
17. Returns a copy of the string as all lower case
lc($string)
push(@array, $newValue)
similar data types
%ENV hash array
18. To write to a filehandle
uc($string)
Assignment
@ARGV
print(FILEHANDLE "Data to outputn");
19. ________ in perl - can be scalar array or hash context - tells the interpreter what you are looking for (Ex: "$arrayname[$index_number]")
@ARGV
Variable context
uc($string)
basic binding operators
20. eq - ne - lt - le - gt - ge
size string comparison operators
split(/\s/, $string)
hash functions
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
21. The three basic ________ of the open() function: > write - >> append - < read file
Special array
access modes
reverse(@array)
Expression Quantifiers
22. Regular __________: * - 0 or more characters - + - 1 or more characters - ? - 0 or 1 characters
ucfirst($string)
values(%hash)
Expression Quantifiers
access modes
23. _________ @arrayName) returns the size of the array
comments
scalar
unshift(@array, $newValue)
$hashName{keyName}="Value to Add"
24. Assignment of hash variables in perl (when oringally defining the hash)
@ARGV
Special array
last index
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
25. scalar(@arrayName) returns the ______ of the array names
command substitution
@arrayName size
array functions
use moduleName; Ex: use Roman;
26. Returns all of the keys of the hash as an array
values(%hash)
keys(%hash)
join(':', @array)
comments
27. To get rid of the ________ in $line you could now chomp() (Ex: chomp($line);)
size string comparison operators
newline
access modes
Special array
28. Common ________: pop(@array) - push(@array, $new Value) - shift(@array) - unshift(@array, $newValue) - sort(@array) - reverse(@array)
array functions
scalar
Expression character classes
Assignment
29. To read an entire file into an array (one line per element)
size string comparison operators
@entireFile=<FILEHANDLE>
push(@array, $newValue)
newline
30. 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
Array variables
interpreter
command substitution
Hash variables
31. Two ____________ in regular expressions: =~ Contains - !~ Does not contain
basic binding operators
Array variables
system() function
exists($hashName{keyName})
32. _________ in perl - An associative array
Hash variables
access modes
foreach
Special array
33. Join the elements of the array seperating the elements with the ':' character
Warning
: Invalid argument supplied for foreach() in
/var/www/html/basicversity.com/show_quiz.php
on line
183
34. Modules in perl - Synonymous with header files in C - Collection of ______ and variables that may be used in your program
Expression Quantifiers
like functions
uc($string)
push(@array, $newValue)
35. Add a new element to the from of the array with the value $newwValue
unshift(@array, $newValue)
length($string)
FILEHANDLE
$#arrayName
36. 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
each(%hash)
system() function
Variable context
lcfirst($string)
37. ________ in perl - A collection of data (static data or scalar variables or arrays or hashes can all be stored in an array element)
chomp(@string)
Array variables
Variable context
@arrayName size
38. 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
$#arrayName
chomp(@string)
Expression Quantifiers
39. Arrays can be assigned or read in _________
exists($hashName{keyName})
size string comparison operators
lc($string)
scalar context (Ex: $myArray[4] = 2)
40. Assignment of a hash variable for a single hash element
(@array)
@entireFile=<FILEHANDLE>
access modes
$hashName{keyName}="Value to Add"
41. 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
%hashname = (key1=>"value1", key2=>"value2", key3=>"Value3")
interpreter
unshift(@array, $newValue)
execution block
42. Remove trailing newline from each element in the array
exists($hashName{keyName})
lcfirst($string)
flow-control
chomp(@string)
43. Common ________: keys(%hash) - values(%hash) - each(%hash) - delete($hash{keyName}) - exists($hash{keyName}) - reverse(%hash)
system commands
join(':', @array)
hash functions
size string comparison operators
44. Adds a new element to end of the array with value $newValue
like functions
push(@array, $newValue)
join(':', @array)
string manipulation functions
45. Stores information about the current users environment. You can print this from the command line using printenv
array functions
%ENV hash array
each(%hash)
substr($string, $startindex, $numchars)
46. The four types of loops in perl: while - until - for - ________
print(FILEHANDLE "Data to outputn");
uc($string)
foreach
system() function
47. Swap keys for values and values for keys. Will cause issues if there are multiple hash entries with the same value
comments
reverse(@array)
flow-control
reverse(%hashName)
48. Removes the last element from the array pop
keys(%hash)
use moduleName; Ex: use Roman;
(@array)
Array variables
49. The use of "if" "if-else" and "if-elsif-else"
flow-control
ucfirst($string)
lcfirst($string)
@ARGV
50. Returns a copy of the string as all upper case
each(%hash)
$hashName{keyName}="Value to Add"
$line=<FILEHANDLE>
uc($string)