亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch3.htm

?? prrl 5 programs codes in the book
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<HTML>

<HEAD>

<TITLE>Chapter 3 -- Variables</TITLE>



<META>

</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">

<H1><FONT SIZE=6 COLOR=#FF0000>Chapter&nbsp;3</FONT></H1>

<H1><FONT SIZE=6 COLOR=#FF0000>Variables</FONT></H1>

<HR>

<P>

<CENTER><B><FONT SIZE=5>CONTENTS</FONT></B></CENTER>

<UL>

<LI><A HREF="#ScalarVariables">

Scalar Variables</A>

<UL>

<LI><A HREF="#ExampleAssigningValuestoScalarVariables">

Example: Assigning Values to Scalar Variables</A>

<LI><A HREF="#ChangingValuesinScalarVariables">

Changing Values in Scalar Variables</A>

</UL>

<LI><A HREF="#ArrayVariables">

Array Variables</A>

<UL>

<LI><A HREF="#ExampleAssigningValuestoArrayVariables">

Example: Assigning Values to Array Variables</A>

<LI><A HREF="#ExampleUsingArrayElements">

Example: Using Array Elements</A>

<LI><A HREF="#ExampleUsingNegativeSubscripts">

Example: Using Negative Subscripts</A>

<LI><A HREF="#ExampleDeterminingtheNumberofElementsinanArray">

Example: Determining the Number of Elements in an Array</A>

<LI><A HREF="#ExampleHowtoGrabaSliceorPartofanArray">

Example: How to Grab a Slice (or Part) of an Array</A>

</UL>

<LI><A HREF="#AssociativeArrayVariables">

Associative Array Variables</A>

<UL>

<LI><A HREF="#ExampleAssigningValuestoAssociativeArrayVariables">

Example: Assigning Values to Associative Array Variables</A>

</UL>

<LI><A HREF="#DoubleQuotedStringsRevisited">

Double-Quoted Strings Revisited</A>

<UL>

<LI><A HREF="#ExampleVariableInterpolation">

Example: Variable Interpolation</A>

<LI><A HREF="#ExampleUsingtheIquotISpecialVariable">

Example: Using the <I>$&quot;</I> Special Variable</A>

</UL>

<LI><A HREF="#Summary">

Summary</A>

<LI><A HREF="#ReviewQuestions">

Review Questions</A>

<LI><A HREF="#ReviewExercises">

Review Exercises</A>

</UL>



<HR>

<P>

In the last chapter, you learned about <I>literals</I>-values

that don't change while your program runs because you represent

them in your source code <I>exactly</I> as they should be used.

Most of the time, however, you will need to change the values

that your program uses. To do this, you need to set aside pieces

of computer memory to hold the changeable values. And, you need

to keep track of where all these little areas of memory are so

you can refer to them while your program runs.

<P>

Perl, like all other computer languages, uses variables to keep

track of the usage of computer memory. Every time you need to

store a new piece of information, you assign it to a variable.

<P>

You've already seen how Perl uses numbers, strings, and arrays.

Now, you'll see how to use variables to hold this information.

Perl has three types of variables:<BR>



<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD WIDTH=151><I>Variable Type</I></TD><TD WIDTH=439><I>Description</I>

</TD></TR>

<TR><TD WIDTH=151>Scalars</TD><TD WIDTH=439>Holds one number or string value at a time. Scalar variable names always begin with a <TT>$</TT>.

</TD></TR>

<TR><TD WIDTH=151>Arrays</TD><TD WIDTH=439>Holds a list of values. The values can be numbers, strings, or even another array. Array variable names always begin with an <TT>@</TT>.

</TD></TR>

<TR><TD WIDTH=151>Associative Arrays</TD><TD WIDTH=439>Uses any value as an index into an array. Associative array variable names always begin with an .

</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

The different beginning characters help you understand how a variable

is used when you look at someone else's Perl code. If you see

a variable called <TT>@Value</TT>,

you automatically know that it is an array variable.

<P>

They also provide a different <I>namespace</I> for each variable

type. Namespaces separate one set of names from another. Thus,

Perl can keep track of scalar variables in one table of names

(or namespace) and array variables in another. This lets you use

<TT>$name</TT>, <TT>@name</TT>,

and <TT>%name</TT> to refer to different

values.<BR>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Tip</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

I recommend against using identical variable names for different data types unless you have a very good reason to do so. And, if you do need to use the same name, try using the plural of it for the array variable. For example, use <TT>$name</TT> for the 
scalar variable name and <TT>@names</TT> for the array variable name. This might avoid some confusion about what your code does in the future.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Note</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

Variable names in Perl are case-sensitive. This means that <TT>$varname</TT>, <TT>$VarName</TT>, <TT>$varName</TT>, and <TT>$VARNAME</TT> all refer to different variables.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

Each variable type will be discussed in its own section. You'll

see how to name variables, set their values, and some of the uses

to which they can be put.

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

Scalar Variables</FONT></A></H2>

<P>

Scalar variables are used to track single pieces of information.

You would use them to hold the title of a book or the number of

rooms in a house. You can use just about any name imaginable for

a scalar variable as long as it begins with a <TT>$</TT>.

<BR>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Tip</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

If you have programmed in Visual Basic, you need to be especially careful when naming variables. Just remember that <I>all</I> scalars begin with a <TT>$</TT>, not just strings, and that the <TT>$</TT> starts the name; it doesn't end it.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

Let's jump right in and look at some variable names.

<P>

<IMG SRC="pseudo.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/pseudo.gif" BORDER=1 ALIGN=RIGHT><p>

<BLOCKQUOTE>

<I>This scalar variable will hold the number of rooms.<BR>

This scalar variable will hold the title of a book.<BR>

This scalar variable conflicts with a Perl special variable that

you'll learn about in <A HREF="ch12.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch12.htm" >Chapter 12</A>, &quot;Using Special Variables.&quot;</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$numberOfRooms

$bookTitle

$0<BR>



</PRE>

</BLOCKQUOTE>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Note</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

It is generally a good idea to stay away from short variable names. Longer variable names are more descriptive and aid in understanding programs.</BLOCKQUOTE>

<BLOCKQUOTE>

Let me say a quick word about variable names. I always start my variable names with a lowercase letter and then make the first letter of each &quot;word&quot; in the name uppercase. Some programmers like to separate each word with an underscore. For 
example, <TT>$numberOfRooms</TT> would look like <TT>$number_of_rooms</TT>. Choose a method that you feel comfortable with and then stick with it. Being consistent will make your program more understandable.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

Most programmers try to use descriptive names for their variables.

There is no practical limit to the length of a Perl variable name,

but I like to keep them under 15 characters. Anything longer than

that means that it will take a while to type them and iNCreases

the chaNCes of spelling errors.

<H3><A NAME="ExampleAssigningValuestoScalarVariables">

Example: Assigning Values to Scalar Variables</A></H3>

<P>

Now that you know what scalar variable names look like, we'll

look at how you can assign a value to them. Assigning values to

a variable is done with the equals (=) sign.

<P>

<IMG SRC="pseudo.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/pseudo.gif" BORDER=1 ALIGN=RIGHT><p>

<BLOCKQUOTE>

<I>Assign a value of 23 to a variable called </I><TT><I>$numberOfRooms</I></TT><I>.

<BR>

Assign a value of Perl by Example to a variable called </I><TT><I>$bookTitle</I></TT><I>.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$numberOfRooms = 23;

$bookTitle = &quot;Perl by Example&quot;;

</PRE>

</BLOCKQUOTE>

<P>

Notice that you are assigning literal values to the variables.

After assigning the values, you then can change them.

<H3><A NAME="ChangingValuesinScalarVariables">

Changing Values in Scalar Variables</A></H3>

<P>

The next example will make a variable assignment and then change

that variable's value using a second assignment. The second assignment

will iNCrement the value by five.

<P>

<IMG SRC="pseudo.gif" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/pseudo.gif" BORDER=1 ALIGN=RIGHT><p>

<BLOCKQUOTE>

<I>Assign a value of 23 to a variable called </I><TT><I>$numberOfRooms</I></TT><I>.

<BR>

Add 5 to the </I><TT><I>$numberOfRooms</I></TT><I>

variable.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$numberOfRooms = 23;

$numberOfRooms = $numberOfRooms + 5;<BR>



</PRE>

</BLOCKQUOTE>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Note</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

In Perl, you never have to declare, define, or allocate simple data types (for example: scalars, arrays, or associative arrays). When you use the variable for the first time, Perl either assigns it a zero if you need a number or an empty list if you need 
an array. Using a variable name is equivalent to defining it.</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Caution</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

Letting Perl automatically initialize variables is fine for small programs. However, if you write professional programs that need to be maintained, you'll want to explicitly declare variables using the <TT>my()</TT> fuNCtion. Explicitly declaring 
fuNCtions will reduce errors and improve the internal documentation of your programs. The <TT>my()</TT> fuNCtion is discussed in <A HREF="ch5.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch5.htm" >Chapter 5</A> &quot;FuNCtions.&quot;

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

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

Array Variables</FONT></A></H2>

<P>

You had a short introduction to arrays last chapter when you printed

out entire arrays (with no spaces, remember?) using Perl's <TT>print

</TT>statement. Now, you'll learn about arrays in more

detail. Array variable names always begin with an <TT>@</TT>

character.<BR>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Tip</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

I remember that the <TT>@</TT> sign starts array variables because &quot;at&quot; and &quot;array&quot; start with the same letter. Simple&#133;but it works for me.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

The rules for naming array variables are the same as those for

scalar variables. There are no rules. Well, none that you need

to worry about. In fact, let's skip looking at variable names

and get right to assigning arrays to variables, instead.

<H3><A NAME="ExampleAssigningValuestoArrayVariables">

Example: Assigning Values to Array Variables</A></H3>

<P>

You use the equals (=) sign to assign values to array variables

just like scalar values.

<P>

We'll use one of the examples from <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;-reworked a little-so you'll already be familiar

with part of the example.<BR>

<p>

<CENTER>

<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>

<TR><TD><B>Tip</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

The printing of the newline character is separated from the printing of the array for a reason. It has to do with how Perl interprets variables in different contexts. If you tried to use <TT>print @numberArray . &quot;\n&quot;</TT>; Perl thinks that you 
want to use <TT>@numberArray</TT> in a scalar context and won't print the elements of the array. It will print the number of elements instead. See the section, &quot;Example: Determine the Number of Elements in an Array,&quot; later in this chapter.

</BLOCKQUOTE>



</TD></TR>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re8在线精品视频免费播放| 亚洲一区二区在线播放相泽| 欧美吻胸吃奶大尺度电影| av资源网一区| 91网站在线观看视频| 91在线一区二区三区| 99精品欧美一区二区三区小说| www.久久精品| 91同城在线观看| 成人免费看的视频| 91丨porny丨中文| 欧美在线短视频| 8x8x8国产精品| 久久婷婷成人综合色| 欧美激情一区三区| 一区二区三区在线不卡| 亚洲一区二区精品久久av| 人人精品人人爱| 蜜桃视频一区二区三区在线观看| 久久91精品国产91久久小草| 国产精品亚洲一区二区三区在线 | 国产一区三区三区| 国产在线视频不卡二| 色综合色综合色综合色综合色综合| 欧美日韩在线播放三区四区| 日韩欧美一级在线播放| 亚洲国产一区视频| 成人精品一区二区三区四区 | 亚洲裸体xxx| 一区二区三区在线高清| 丝袜诱惑亚洲看片| 国产成人自拍网| 欧美三级中文字| 国产日韩成人精品| 亚洲一区二区三区四区五区黄| 蜜桃视频一区二区| 丝袜美腿亚洲综合| 91老司机福利 在线| 欧美日本一道本| 久久久99久久| 五月婷婷激情综合网| 国产一区二区剧情av在线| 91精品国产综合久久婷婷香蕉 | 欧美成人免费网站| 国产精品水嫩水嫩| 青青草97国产精品免费观看无弹窗版| 亚洲天堂av老司机| 精品免费99久久| 日本欧美一区二区三区乱码| 99久久国产综合精品色伊| 91影视在线播放| 欧美日韩久久久| 成人综合婷婷国产精品久久免费| 欧美一区二区久久久| 国产精品久久久久久福利一牛影视| 国产激情视频一区二区在线观看| 欧美日产国产精品| 日本三级亚洲精品| 欧美日韩一级大片网址| 婷婷一区二区三区| www成人在线观看| 成人性生交大片免费看视频在线| 丝袜美腿亚洲色图| 亚洲免费av观看| 中文一区在线播放| 欧美国产日韩一二三区| 久久欧美中文字幕| 在线观看av一区| 色婷婷久久久久swag精品| 五月激情综合网| 亚洲黄色小视频| 欧美大片免费久久精品三p| 色婷婷国产精品久久包臀| 97久久超碰精品国产| 日本网站在线观看一区二区三区| 久久婷婷综合激情| 国产激情精品久久久第一区二区| 亚洲国产精品传媒在线观看| 91小视频在线| 粉嫩在线一区二区三区视频| 丝袜诱惑亚洲看片| 亚洲日本丝袜连裤袜办公室| 久久久精品天堂| 欧美亚洲动漫另类| 男女男精品视频网| 粉嫩13p一区二区三区| 成人午夜电影久久影院| 九一九一国产精品| 成人动漫一区二区| 成人综合在线观看| 91精品国模一区二区三区| 老司机精品视频一区二区三区| 国内成人免费视频| 久久精品国内一区二区三区| 老汉av免费一区二区三区| 在线精品观看国产| 日本一区二区三区视频视频| 亚洲成人自拍网| 青青草国产精品97视觉盛宴| 精品欧美一区二区久久 | 亚洲高清视频中文字幕| 欧美日本一区二区在线观看| 麻豆国产精品一区二区三区| 久久青草国产手机看片福利盒子| 成人国产在线观看| 亚洲妇熟xx妇色黄| 2欧美一区二区三区在线观看视频| 国产精品亚洲成人| 亚洲精品大片www| 日韩一区和二区| 97久久超碰精品国产| 日本午夜精品一区二区三区电影| 久久久高清一区二区三区| 99在线热播精品免费| 日韩二区三区四区| 国产精品人人做人人爽人人添| 精品视频在线看| 国产精品中文有码| 亚洲曰韩产成在线| 国产三级一区二区三区| 在线看国产一区二区| 韩国在线一区二区| 一区二区三区不卡在线观看| 久久综合中文字幕| 欧美日韩精品三区| 成人午夜看片网址| 久久精品国产一区二区三区免费看| 18涩涩午夜精品.www| 日韩情涩欧美日韩视频| 色综合久久久久网| 国产精品主播直播| 日韩中文字幕av电影| 综合在线观看色| 国产日韩在线不卡| 日韩欧美www| 欧美一区二区三区小说| 91免费看`日韩一区二区| 国产成人在线免费观看| 美女被吸乳得到大胸91| 亚洲成人一区在线| 亚洲精品v日韩精品| 国产精品看片你懂得| 国产欧美一区二区精品仙草咪 | 蜜桃av噜噜一区| 亚洲午夜久久久久久久久久久| 国产精品理论片| 欧美国产日本视频| 国产三级精品三级| 国产肉丝袜一区二区| 国产亚洲欧美中文| 2020国产精品自拍| 精品久久久久久久久久久久包黑料| 欧美体内she精高潮| 欧美日韩精品电影| 欧美日韩精品欧美日韩精品一| 欧美性受xxxx黑人xyx性爽| 在线免费观看成人短视频| 91久久精品午夜一区二区| 欧美综合色免费| 精品视频在线免费观看| 69久久夜色精品国产69蝌蚪网| 7777精品伊人久久久大香线蕉 | 国产精品1区2区| 风间由美性色一区二区三区| 成人激情综合网站| 99精品偷自拍| 色综合久久久网| 欧美理论片在线| 日韩午夜小视频| 亚洲精品一区二区在线观看| 欧美精品一区二区三区很污很色的 | 欧美色老头old∨ideo| 欧美日韩一区在线观看| 日韩你懂的在线播放| 久久综合九色综合久久久精品综合| 久久精品夜色噜噜亚洲a∨| 国产精品久久免费看| 亚洲国产成人tv| 久久精品国内一区二区三区| 成人免费视频网站在线观看| 欧美在线999| 欧美成人三级在线| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 自拍偷拍国产亚洲| 蜜臀久久99精品久久久久宅男 | 在线观看区一区二| 日韩美女在线视频| 亚洲欧洲日韩av| 蓝色福利精品导航| 99久久精品一区| 日韩精品中文字幕在线不卡尤物| 国产日韩高清在线| 日本在线不卡一区| 北岛玲一区二区三区四区| 91精品欧美福利在线观看| 国产精品美女久久久久高潮| 午夜电影网亚洲视频| 不卡一区二区三区四区| 欧美tickle裸体挠脚心vk| 亚洲在线成人精品|