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