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