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