Final - Chapter 9 Flashcards

1
Q
  1. Which of the following describes Common Gateway Interface (CGI). (Choose all
    that apply.)
    a. It facilitates the exchange of information over theWeb.
    b. It is a specialized interface for using Java scripts only.
    c. It is a security program to protect a server.
    d. It is a protocol or set of rules.
A

A and D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Your colleague is writing a Perl script and wants to determine if two strings are the same. He used the = operator, but it is not working properly. What is the problem?

a. He should use the ! = operator, instead.
b. He did not surround the strings with square brackets to show they are strings.
c. He should use the eq operator, instead.
d. He should use , instead.

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
3. In Perl a variable that starts with $, such as $value, . (Choose all
that apply.)
a. cannot be zero
b. can be numeric
c. can be nonnumeric
d. is scalar
A

B,C,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
4. Which of the following operators is used to access data in an open file in Perl?
(Choose all that apply.)
a. #
b. @
c. ( )
d. <>
A

B and D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. You are training a new employee and have been asked to help him learn Perl. Which of the following statements can you use to help describe Perl? (Choose all that
    apply. )
    a. It is only used on UNIX and Linux systems.
    b. It is popularly used to create reports, such as business reports.
    c. It is a language that requires compiling.
    d. It can be used to manipulate text and numeric information.
A

B and D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. You have created the following expression in Perl: $value < 2842.What does this expression mean?
    a. The size of the value file is 2842 kilobytes.
    b. The file 2842 is opened and given the name value for the purpose of the current
    Pearl script.
    c. The variable value is less than 2842.
    d. 2842 is written to the file called value.
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. A programmer in your group has written the following subroutine, which does not work. What is the problem?
run sort
{
if ($a < $b) { -1; }
elsif ($a == $b) { 0; }
else { +1; }
}
A

He should replace “run” with “sub.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. One of your colleagues has written a Perl script, but it does not run on some people’s computers who use a different Linux distribution or who do not use the Bash shell. Which of the following might be the problem?
a. The script does not have a beginning line that contains the path to Perl, such as
#!/usr/bin/perl.
b. Perl can only be run in the Bash shell.
c. The script does not contain the line to specify it is a Perl script, which is make= perl.
d. Perl does not run in the root account, which must be the account some users are accessing to run this Perl script.
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. A colleague at work has overheard you discussing the spaceship operator and is curious
    about what this is.What do you tell him?
    a. It refers to a Perl script that has bugs.
    b. It deletes one or more files in Perl.
    c. It is a Perl formatting editor that helps speed the writing of Perl scripts.
    d. It performs numeric sorts in Perl.
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. You are writing a Perl script that uses a segment of code over and over again,
    and you are tired of repeatedly typing in this code.Which of the following should
    you do?
    a. Create a subroutine.
    b. Use the =+= repeat operator.
    c. Use the ++ operator.
    d. Create a repeat script.
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. Which of the following are automatically opened by Perl? (Choose all that apply.)
    a. A.OUT
    b. STDOUT
    c. STDERR
    d. CORE
A

B and C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. In the following statement, when is “Could not open students file” displayed?
    open (FILEIN, “students”) || warn “Could not open students
    file \n” ;
    a. When open (FILEIN, “students”) is false.
    b. When open (FILEIN, “students”) is true.
    c. When the last row of data has been read from the students file.
    d. When the students file is larger then 1.5 MB.
A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. When you make aWeb page using HTML, what line do you start with to show that
    what follows after that line consists of HTML tags?
    a. #START
    b. /NEW
    c.
    d. /BEGIN/
A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Which of the following is an example of a scalar? (Choose all that apply.)
    a. $income = 62,859;
    b. $lname = “McGregor”;
    c. value = 10,Tiger;
    d. @cell* = B10;
A

A and B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. You have written the following line in a Perl program:
    $filein = $ARGV[0];
    What is the purpose of this line?
    a. It copies a file to the ARGV directory.
    b. It closes a file.
    c. It searches for a file in all subdirectories under a directory.
    d. It saves the name of a file passed from the command line in ARGV[0].
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. In Perl, the control sequence \n is used to .
    a. designate a horizontal tab
    b. designate a new line
    c. force the next character to be lowercase
    d. make a bell sound
A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  1. You are creating a data file for an inventory system.Which of the following is a
    common file extension to show this is a data file?
    a. .c
    b. .dat
    c. .a
    d. .zip
A

B

18
Q
  1. Perl supports using which of the following logic structures? (Choose all that apply.)
    a. if statement
    b. while loop
    c. index jump
    d. presort loop
A

A,B,C

19
Q
  1. In Perl, strings are surrounded by which of the following? (Choose all that apply.)
    a. double commas
    b. colons
    c. percent signs
    d. single or double quotation marks
A

D

20
Q
  1. You colleague is creating an HTML-basedWeb page and wants the first line to have
    the largest heading size, and so he uses the tag .This tag isn’t producing
    the expected result.What tag should he use instead?
    a.
    b.
    c. <h1>
    d. </h1>
A

C

21
Q
21. When you assign values for an array, what character should precede the name of the
array?
a. +
b. \A
c. @
d. ^
A

C

22
Q
  1. What arithmetic operators are used in Perl scripts?
A

+ for addition
- for subtraction
* for multiplication
/ for division

23
Q
  1. What is a filehandle in Perl?
A

It is the name for an I/O connection and is used to open, read, write to, or close a file that you are accessing.

24
Q
  1. Name at least one difference between Perl and Awk programming.
A
  • Awk does not require explicitly setting up looping structures.
  • Awk uses fewer lines of code for pattern-matching extractions
25
Q
  1. Name five data types used by Perl.
A

variables, constants, scalars, numbers, strings, arrays, and hashes.

26
Q
  1. ____ are sequences of any types of characters (including numbers that are treated as characters rather than digits).
A

Strings

27
Q
  1. A(n) ____ is a simple variable that holds a number or a string.
A

scalar

28
Q
  1. The value of a variable can change while a program runs.(T/F)
A

True

29
Q
  1. If the ____ option is not included, the Awk program uses the first command-line argument as its program.
A

-f

30
Q
  1. When processing the individual elements of an array, use the ____ character.
A

$

31
Q
  1. The name of the computer at the loopback address is ____.
A

localhost

32
Q
  1. In Perl, print; is equivalent to ____.
A

“$_”;.

33
Q
  1. A(n) ____ is a variable that represents a set of key/value pairs.
A

hash

34
Q
  1. The convention is to use all uppercase letters for ____.
A

filehandles

35
Q
  1. In Perl, the logical OR operator is ____.
A

||

36
Q
  1. The following example shows a(n) ____ variable: %animals = (‘Tigers’, 10, ‘Lions’, 20, ‘Bears’, 30);
A

hash

37
Q
  1. The ____ feature allows your UNIX or Linux system to access its own internal network configuration instead of an external network.
A

loopback

38
Q
  1. The character sequence ____ quotes all following nonalphanumeric characters until \E is encountered.
A

\Q

39
Q
  1. All complete statements in Perl end with a(n) ____.
A

semicolon

40
Q
  1. The Awk program does not require the programmer to explicitly set up looping structures as does Perl.(T/F)
A

True