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