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