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