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