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