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