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