⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch23.htm

📁 prrl 5 programs codes in the book
💻 HTM
📖 第 1 页 / 共 3 页
字号:
script by the operating system.

<LI>What will the statement <TT>$SIG{'ABRT'}

= 'IGNORE'</TT> do?<BR>

You can cause Perl to ignore the Ctrl+c key sequeNCe by placing

this line of code near the beginning of your program.

<LI>Which signal is used to trap floating point exceptions?<BR>

<B>FPE-</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 14</FONT></A></H2>

<OL>

<LI>What is an object?<BR>

<B>Actually, &quot;What are objects?&quot; is a silly question

because you already know what an object is. Trust your instiNCts.

The book you are reading is an object. The knife and fork that

you eat with are objects. In short, your life is filled with them.</B>

<LI>What is a class?<BR>

<B>The question that really needs to be asked is, &quot;What are

classes?&quot; You see, all object oriented techniques use classes

to do the real work. A <I>class</I> is a combination of variables

and fuNCtions designed to emulate an object. However, when referring

to variables in a class, object-oriented folks use the term <I>properties</I>.

And when referring to fuNCtions in a class, the term <I>method</I>

is used.</B>

<LI>What is a property?<BR>

<B>Variables in a class.</B>

<LI>What does the term polymorphism mean?<BR>

<B>A child class can redefine a method already defined in the

parent class.</B>

<LI>Is the <TT>bless()</TT> fuNCtion

used to create classes?<BR>

<B>No. The </B><TT><B><FONT FACE="Courier">bless()</FONT></B></TT><B>

fuNCtion is used to change the data type of the anonymous hash

to </B><TT><B><FONT FACE="Courier">$class</FONT></B></TT><B> or

</B><TT><B><FONT FACE="Courier">Inventory_item</FONT></B></TT><B>.</B>

<LI>What does the <TT>package</TT>

keyword do?<BR>

<B>The </B><TT><B><FONT FACE="Courier">package</FONT></B></TT><B>

keyword is used to introduce new classes and namespaces.</B>

<LI>What can a static variable be used for?<BR>

<B>Static variables can be used to emulate <I>constants</I>-values

that don't change.</B>

<LI>Why is it good to use anonymous hashes to represent objects

instead of regular arrays?<BR>

<B>Child classes, in Perl, will not automatically inherit properties

from its parents. However, using anonymous hashes totally avoids

this issue because the parent constructor can be explicitly called

to create the object. Then, the child can simply add entries to

the anonymous hash.</B>

<LI>How can you create a fuNCtion that is available to all classes

in your script?<BR>

<B>Start a definition of the </B><TT><B><FONT FACE="Courier">UNIVERSAL</FONT></B></TT><B>

class.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 15</FONT></A></H2>

<OL>

<LI>What is a module?<BR>

<B>A <I>module</I> is a namespace defined in a file. For example,

the </B><TT><B><FONT FACE="Courier">English</FONT></B></TT><B>

module is defined in the </B><TT><B><FONT FACE="Courier">English.pm</FONT></B></TT><B>

file and the </B><TT><B><FONT FACE="Courier">Find</FONT></B></TT><B>

module is defined in the </B><TT><B><FONT FACE="Courier">Find.pm</FONT></B></TT><B>

file.</B>

<LI>What is the correct file extension for a module?<BR>

<B>.pm</B>

<LI>What is a pragma?<BR>

<B>It turns other compiler directives on and off.</B>

<LI>What is the most important pragma and why?<BR>

<B>The most important pragma is </B><TT><B><FONT FACE="Courier">strict</FONT></B></TT><B>.

This pragma generates compiler errors if unsafe programming is

detected.</B>

<LI>What does the <TT>END</TT> block

do?<BR>

<TT><B><FONT FACE="Courier">END</FONT></B></TT><B> blocks write

a message to a log file about end times for the program.</B>

<LI>What is a symbol table and how are they named?<BR>

<B>A <I>symbol table</I>, in Perl, is a hash that holds all of

the names defined in a namespace. All of the variable and fuNCtion

names can be found there. The hash for each namespace is named

after the namespace with two colons.</B>

<LI>How can you create a variable that is local to a package?

<BR>

<B>Fully qualify your variable name in the declaration or initialization

statement.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 16</FONT></A></H2>

<OL>

<LI>What is a logic error?<BR>

<I><B>Logic</B></I><B> errors are insidious and difficult to find.

For example, you might place an assignment statement inside an

</B><TT><B><FONT FACE="Courier">if</FONT></B></TT><B> statement

block that belongs outside the block. Or you might have a loop

that runs from 0 to 100 when it should run from 10 to 100. Accidentally

deleting the 1 or not entering it in the first place is very easy.</B>

<LI>What is a compile-time error?<BR>

<B>Compile-time errors are also known as syntax errors and are

made as you type your script into an editor.</B>

<LI>What will the <TT>D</TT> debugger

command do?<BR>

<B>Deletes all breakpoints.</B>

<LI>What is a conditional breakpoint?<BR>

<B>A</B> <B>breakpoint that occurs only when certain criteria

are met.</B>

<LI>What will the <TT>c</TT> debugger

command do?<BR>

<B>Executes the rest of the statements in your script unless a

breakpoint is found before the script ends. You can optionally

use this command to create a temporary break by specifying a line

number after the </B><TT><B><FONT FACE="Courier">c</FONT></B></TT><B>.</B>

<LI>Can you invoke any fuNCtion directly from the debugger command

line?<BR>

<B>Yes.</B>

<LI>What is an alias?<BR>

<B>An alias is a way of assigning a name to a long command used

over and over again.</B>

<LI>What is a common error associated with conditional expressions?

<BR>

<B>One of the most common logic problems is using the assignment

operator (</B><TT><B><FONT FACE="Courier">=</FONT></B></TT><B>)

when you should use the equality operator (</B><TT><B><FONT FACE="Courier">==</FONT></B></TT><B>).

If you are creating a conditional expression, you'll almost always

use the equality operator (</B><TT><B><FONT FACE="Courier">==</FONT></B></TT><B>).</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 17</FONT></A></H2>

<OL>

<LI>What is a command-line option?<BR>

<B>Command-line options (also called switches) turn on and off

different behaviors of the Perl interpreter.</B>

<LI>What are the two places that the switches can be specified?

<BR>

<B>Switches can be placed either on the command line that invokes

Perl or in the first line of the program.</B>

<LI>What switch should always be used?<BR>

<B>You should always use the -w switch to turn on the extended

warning option.</B>

<LI>Which switch lets you read records that end with the ~ character

instead of the newline?<BR>

<B>The -o switch lets you specify the record delimiter character.</B>

<LI>What two options can be used with the <TT>-n</TT>

option?<BR>

<B>The -a and -F options can be used with the -n.</B>

<LI>How can you execute a script that someone sent you via e-mail?

<BR>

<B>The -x option can be used to execute a script from the middle

of the file.</B>

<LI>What happens if you specify both the <TT>-v</TT>

and the <TT>-c</TT> options?<BR>

<B>The -v option displays the Perl version number and then the

-c option checks the syntax of any Perl script specified on the

command line.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 18</FONT></A></H2>

<OL>

<LI>What is a protocol?<BR>

<B>A protocol is a set of commands and responses.</B>

<LI>What is a socket?<BR>

<I><B>Sockets</B></I><B> are the low-level links that enable Internet

conversations.</B>

<LI>What is the POP?<BR>

<B>Post Office Protocol-iNComing mail.</B>

<LI>Will client programs use the <TT>bind()</TT>

fuNCtion?<BR>

<B>No.</B>

<LI>Do newly created sockets have an address?<BR>

<B>No.</B>

<LI>What is a port?<BR>

<B>A <I>Port</I> is an imaginary place where iNComing packets

of information can arrive (just like a ship arrives at a sea port).</B>

<LI>When sending the body or text of an e-mail message, will the

server respond after each line?<BR>

<B>Yes.</B>

<LI>Why shouldn't the echo service be used by Windows operating

systems?<BR>

<B>Windows 95 (and perhaps other operating systems) can't use

the SIGALRM interrupt signal. This may cause problems if you use

this script on those systems because the program will wait forever

when a server does not respond.</B>

<LI>What is the largest NNTP reponse in terms of bytes?<BR>

<B>Unlimited.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 19</FONT></A></H2>

<OL>

<LI>Is CGI a programming language?<BR>

<B>No.</B>

<LI>Are CGI and Java the same type of protocol?<BR>

<B>No.</B>

<LI>Do CGI program files need to have the write turned on?<BR>

<B>No.</B>

<LI>What is the first line of output for CGI programs?<BR>

<B>An HTTP header.</B>

<LI>What information does the HTTP_USER_AGENT contain?<BR>

<B>It provides the type and version of the user's Web browser.</B>

<LI>Why is CGItap a useful program?<BR>

<B>It is a CGI debugging aid that can help pinpoint the problem

in a troubling CGI application.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 20</FONT></A></H2>

<OL>

<LI>What does the acronym HTML stand for?<BR>

<B>Hypertext Markup Language.</B>

<LI>What are the <TT>&lt;H1&gt;..&lt;/H1&gt;</TT>

set of tags used for?<BR>

<B>It formats text as a first level heading.</B>

<LI>What is the down side of using SSI directives?<BR>

<B>They are very processor intensive.</B>

<LI>Can an HTML form have two submit buttons?<BR>

<B>No.</B>

<LI>Why should all angle brackets be replaced in form information?

<BR>

<B>So that the Web browser doesn't think that a new HTML tag is

starting.</B>

<LI>How much text can be entered into a <TT>&lt;TEXTAREA&gt;</TT>

input field?<BR>

<B>Unlimited.</B>

<LI>Can you debug a CGI script?<BR>

<B>Yes.</B>

</OL>

<H2><A NAME="Chapter"><FONT SIZE=5 COLOR=#FF0000>

Chapter 21</FONT></A></H2>

<OL>

<LI>What is the access log used for?<BR>

<B>It records who and what accesses a specific HTML page or graphic</B>.

<LI>Does the <TT>fullName</TT> field

in the log file correspond to the user's mail address?<BR>

<B>No.</B>

<LI>Why is the status code of the log file entry important?<BR>

<B>To determine if unauthorized people are trying to access secured

<BR>

documents.</B>

<LI>Can you find log file analysis programs on the Internet?<BR>

<B>Yes.</B>

<LI>What good is a customized log file?<BR>

<B>To keep track of who executes your CGI scripts.</B>

<LI>What are two popular features of Web sites?<BR>

<B>The &quot;What's New&quot; page and the Feedback Form.</B>

<LI>What does recursion mean?<BR>

<B>A recursive fuNCtion calls itself in order to get work done.</B>

</OL>

<HR>



<CENTER><P><A HREF="ch22.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch22.htm"><IMG SRC="pc.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/pc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A>

<A HREF="#CONTENTS"><IMG SRC="cc.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/cc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A>

<A HREF="index-1.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/index-1.htm"><IMG SRC="hb.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/hb.gif" BORDER=0 HEIGHT=88 WIDTH=140></A>

<A HREF="ch24.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch24.htm"><IMG SRC="nc.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/nc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A>

<HR WIDTH="100%"></P></CENTER>

</BODY>

</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -