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