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