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