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