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