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