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

📄 ch24.htm

📁 prrl 5 programs codes in the book
💻 HTM
📖 第 1 页 / 共 4 页
字号:
item. Records are broken into fields of information. For example,

a book's title and the author's name might be fields in the records

of the book collection.

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

Data Type</FONT></A></H2>

<P>

The data type is simply the type of information that a variable

holds. Perl has four main data types: scalars, arrays, associative

arrays or hashes, and refereNCes.

<BLOCKQUOTE>

See also <I>Scalars, Arrays, Hashes.</I>

</BLOCKQUOTE>

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

Debugger</FONT></A></H2>

<P>

Perl has a feature that lets you step line-by-line through your

programs. This feature is called a debugger because it is generally

used to find logic errors or bugs in your programs. <A HREF="ch16.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch16.htm" >Chapter 16</A>,

&quot;Debugging Perl,&quot; shows how to use the debugger.

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

Declaration</FONT></A></H2>

<P>

A declaration tells Perl that you want to use a variable. Most

languages require you to declare the variables that you intend

to use. This enables the compiler to perform some optimizations

and perhaps see if you use a variable iNCorrectly. Perl does not

require and does not have any declaration statement-the closest

thing is the <TT>my()</TT> fuNCtion.

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

Deconstructor</FONT></A></H2>

<P>

Deconstructor fuNCtions are used by classes to clean up after

you are done with an object. You might need to close a socket

or file, or to write some log messages. All deconstructor fuNCtions

are named <TT>DESTROY()</TT>.

<BLOCKQUOTE>

See also <I>Classes </I>and <I>Constructor</I>.

</BLOCKQUOTE>

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

Defined</FONT></A></H2>

<P>

A defined variable is one that has been initialized with a value.

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

Delimiter</FONT></A></H2>

<P>

A delimiter is used to tell when one thing ends and another begins.

Delimiters are widely used in text-based databases to separate

one field from another. For example, in the string <TT>&quot;one:two:three&quot;</TT>

the colon is the delimiter. You can break a string into components

based on a delimiter using the <TT>split()</TT>

fuNCtion; you can put the string back together again using the

<TT>join()</TT> fuNCtion.

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

DerefereNCe</FONT></A></H2>

<P>

A refereNCe is a scalar that points to a value. The act of derefereNCing

means to follow the link to arrive at the value. For example,

you can create a refereNCe with the following <TT>$foo

= \10;</TT>. This makes <TT>$foo</TT>

a refereNCe to an anonymous literal value of 10. Printing <TT>$foo</TT>

prints the value of the refereNCe. To get at the value, you need

to derefereNCe $foo like this <TT>${$foo}</TT>.

The symbol in front of the curly brace depends on the type of

refereNCe. Use $ for scalars, @ for arrays, and % for hashes.

<BLOCKQUOTE>

See also <I>RefereNCe</I>.

</BLOCKQUOTE>

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

Detail Line</FONT></A></H2>

<P>

You use detail lines to display information about individual items

in reports. Reports can also have header, footer, subtotal, and

total lines. <A HREF="ch11.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch11.htm" >Chapter 11</A>, &quot;Creating Reports,&quot; has examples

of how to prepare reports.

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

Diamond Operator</FONT></A></H2>

<P>

The diamond operator (<TT>&lt;&gt;</TT>)

is used to read a line of input from a file. Some operating systems,

like UNIX, can use the diamond operator to read from sockets.

<A HREF="ch9.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch9.htm" >Chapter 9</A> &quot;Using Files,&quot; has examples that use the

diamond operator.

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

Directory</FONT></A></H2>

<P>

Directories are used by operating systems and users to group files

in a hierarchical or tree fashion. See your system's documentation

for more information.

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

Dotted Decimal Address</FONT></A></H2>

<P>

All Internet servers have an Internet Protocol (IP) address that

consists of four numbers connected by dots. For example, 207.3.100.98

is the IP address of my personal server. Please don't try connecting

to it though; my IP address changes every day.

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

Empty Strings, Arrays, Lists, and Hashes</FONT></A></H2>

<P>

Empty strings have no characters and have a length and value of

zero. They are literally represented by <TT>&quot;&quot;</TT>.

Empty arrays have no elements and are literally represented by

(&nbsp;). Empty hashes have no entries and are literally represented

by {&nbsp;}. If you have a variable that contains a large string,

you can free up or release memory by assigning the empty string

to it. You can use the same technique to release memory used by

arrays and hashes.

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

ENCapsulation</FONT></A></H2>

<P>

ENCapsulation means that the information about an object (its

properties) and fuNCtions that manipulate that information (its

methods) are stored together.

<BLOCKQUOTE>

See also <I>Abstraction</I>, <I>Classes</I>, <I>InheritaNCe</I>,

and <I>Polymorphism</I>.

</BLOCKQUOTE>

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

ENCryption</FONT></A></H2>

<P>

ENCryption is the act of changing plain text into text which is

not readable. ENCryption enables you to store text while ensuring

that it is safe from prying eyes.

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

Endless Loop</FONT></A></H2>

<BLOCKQUOTE>

See <I>Infinite Loop</I>.

</BLOCKQUOTE>

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

Environment Variables</FONT></A></H2>

<P>

Environment variables are stored by the operating system. You

can change and/or add environment variables on a per-process basis.

Any changes made to environment variables will be passed on to

child processes, but, when your process ends, the changes go away.

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

EOF</FONT></A></H2>

<P>

EOF stands for end-of-file. UNIX uses a character value of 4 to

represent the end-of-file, and DOS/Windows uses a value of 26.

These end-of-file values are ignored in binary mode.

<BLOCKQUOTE>

See also <I>Binary Mode</I>.

</BLOCKQUOTE>

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

Escape SequeNCe</FONT></A></H2>

<P>

In Perl, some letters and characters can have more than one meaning

depending on the situation in which they are used. The period

could mean to match any character in a regular expression or it

could simply be needed to represent a period. You can force Perl

to use a literal context by placing a slash (\) in front of the

character to create an escape sequeNCe. For example, <TT>\.</TT>

means that a regular period should be matched in a regular expression

pattern. This simple definition is complicated by the fact that

some escape sequeNCes have meanings all their own. For example,

<TT>\t</TT> indicates the tab character.<B>

</B>See Table 2.1 in <A HREF="ch2.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch2.htm" >Chapter 2</A> &quot;Numeric and String Literals,&quot;

for a list of all of the special escape sequeNCes.

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

Expression</FONT></A></H2>

<P>

An expression is one or more operands connected by one or more

operators. The operands can be either literal values, variables,

or fuNCtions. For example, <TT>$foo</TT>

is an expression. <TT>$foo + (34 * bar())</TT>

is also an expression. Expressions can be arbitrarily complex.

<BLOCKQUOTE>

See also <I>Statement</I>.

</BLOCKQUOTE>

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

FF</FONT></A></H2>

<P>

FF is the abbreviation for form feed or page eject. This character

is typically sent to a printer to force a page ejection. An FF

is represented by \f in strings. The form feed can also be referred

to as Ctrl+L, ^L, 0x0b, or as an ASCII value of 12.

<BLOCKQUOTE>

See also <I>ASCII </I>and  <I>Control Characters</I>.

</BLOCKQUOTE>

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

Field</FONT></A></H2>

<BLOCKQUOTE>

See <I>Database</I>.

</BLOCKQUOTE>

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

Filehandle</FONT></A></H2>

<P>

You use a filehandle to let your program access files. It is essentially

a pointer to an internal data structure maintained by the operating

system. Perl naming conventions indicate that all filehandles

should have names that use all capitals.

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

Footer</FONT></A></H2>

<P>

You use footer lines to display information at the bottom of the

page in reports. Reports can also have header, detail-line, subtotal,

and total lines. See <A HREF="ch11.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch11.htm" >Chapter 11</A>, &quot;Creating Reports,&quot;

for more information.

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

Formats</FONT></A></H2>

<P>

You use formats to control a report's appearaNCe. You can specify

both the static text and the variables that will be displayed

in the report. <A HREF="ch11.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch11.htm" >Chapter 11</A>, &quot;Creating Reports,&quot; shows

you how to create reports.

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

ftp</FONT></A></H2>

<P>

ftp is an abbreviation for File Transfer Protocol. This protocol

is used on the Internet to transfer files between two computers.

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

FuNCtion</FONT></A></H2>

<BLOCKQUOTE>

See <I>Procedure</I>.

</BLOCKQUOTE>

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

Globbing</FONT></A></H2>

<P>

You use globbing (what a funny word!) to expand a file specification

into a list of matching files. For example, *.pl might be matched

by <TT>test.pl</TT> and <TT>foo.pl</TT>.

Use the <TT>glob()</TT> fuNCtion to

do your globbing.

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

Greedy Regular Expressions</FONT></A></H2>

<P>

Regular expressions are normally greedy-they try to find the longest

sequeNCe of characters that match a given pattern. For example,

if you use <TT>&quot;qqBqqBqqB&quot;</TT>

as your search space and <TT>/(qqB)+/</TT>

as your pattern, there are three matching possibilities. They

are <TT>&quot;qqB&quot;</TT>, <TT>&quot;qqBqqB&quot;</TT>,

and <TT>&quot;qqBqqBqqB&quot;</TT>.

Perl will find the longest matching string, so <TT>$&amp;</TT>

will be equal to <TT>&quot;qqBqqBqqB&quot;</TT>.

You can reverse this behavior by adding a <TT>?</TT>

to the pattern. For example, <TT>/(qqB)+?/</TT>

will match <TT>&quot;qqB&quot;</TT>.

Don't use the <TT>*</TT> meta-character

with the <TT>?</TT> meta-character

because it will always match the empty string.

<BLOCKQUOTE>

See also <I>Regular Expression</I>.

</BLOCKQUOTE>

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

Grep</FONT></A></H2>

<P>

You use this utility to search files for patterns.

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

Hash</FONT></A></H2>

<BLOCKQUOTE>

See <I>Associative Array</I>.

</BLOCKQUOTE>

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

Header</FONT></A></H2>

<P>

Header lines are used to display information at the top of a report's

page. Reports can also have footer, detail-line, subtotal, and

total lines. <A HREF="ch11.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch11.htm" >Chapter 11</A>, &quot;Creating Reports,&quot; shows you

how to create headers for your reports.

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

Here Documents</FONT></A></H2>

<P>

You use a here document to specify input to a variable or fuNCtion.

It is typically used with the <TT>print()</TT>

fuNCtion. An example will explain better than words:<BR>

<BLOCKQUOTE>

<PRE>

print &lt;&lt;&quot;_END_&quot;;

This is the first line of output.

The value of \$foo is $foo.

This is the third line of output.

_END_



print(&quot;This is the fourth line of output\n&quot;);

</PRE>

</BLOCKQUOTE>

<P>

The syntax for here documents is both freeform and rigid. The

ending label must be immediately to the right of the &lt;&lt;

symbol and must be eNClosed in quotes. The ending label-after

the document-must be by itself on a line and at the beginning

of the line.

<BLOCKQUOTE>

Here, documents are useful if you need to output a lot of lines

at one time.

</BLOCKQUOTE>

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

Hexadecimal</FONT></A></H2>

<P>

Hexadecimal refers to numbers using base 16.

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

Infinite Loop</FONT></A></H2>

<BLOCKQUOTE>

See <I>Endless Loop</I>.

</BLOCKQUOTE>

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

InheritaNCe</FONT></A></H2>

<P>

This is an object-oriented term that means that one object inherits

properties and methods from another object in a parent-child relationship.

<BLOCKQUOTE>

See also <I>Abstraction</I>, <I>Classes</I>, <I>ENCapsulation</I>,

and<I> Polymorphism</I>.

</BLOCKQUOTE>

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

Initialization</FONT></A></H2>

<P>

Initialization is the act of assigning a value to a variable for

the first time or it can also be a series of actions taken to

create a situation. For example, the initialization phase of a

socket program would iNClude getting the protocol and port number,

determining the remote server's address, and creating and binding

a socket.

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

Interpolation</FONT></A></H2>

<P>

Interpolation means the replacement of a variable name with its

value. For example, if <TT>$foo</TT>

equals <TT>&quot;dinner&quot;</TT>

then <TT>&quot;big $foo&quot;</TT>

is equal to <TT>&quot;big dinner&quot;</TT>.

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

⌨️ 快捷键说明

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