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