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