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