亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲国产精品一区二区www在线| 成人av午夜电影| 日本韩国精品在线| 中文字幕精品在线不卡| 国产精品一区二区在线观看网站 | 自拍偷自拍亚洲精品播放| 免费观看一级特黄欧美大片| 欧美日本高清视频在线观看| 亚洲免费观看高清完整| 色综合天天综合网天天狠天天| 中文字幕精品一区二区精品绿巨人| 国产一区二区三区综合| 欧美电影免费观看高清完整版| 日韩国产欧美三级| www.亚洲精品| 久久女同精品一区二区| 国产乱人伦偷精品视频不卡| 久久亚区不卡日本| 国产真实乱对白精彩久久| 欧美精品自拍偷拍| 久久精品国内一区二区三区| 精品久久久久av影院 | 久久久久久日产精品| 香港成人在线视频| 欧美色综合网站| 日韩电影免费一区| 日韩精品一区二区三区在线观看| 伦理电影国产精品| 国产欧美1区2区3区| caoporn国产一区二区| 中文字幕 久热精品 视频在线| 成人少妇影院yyyy| 亚洲永久免费av| 91精品免费在线观看| 国产在线不卡一卡二卡三卡四卡| 午夜精品福利在线| 日韩免费高清电影| 成人黄色小视频| 亚洲女人小视频在线观看| 欧美老女人第四色| 国产综合久久久久久鬼色| 国产欧美日韩精品一区| 色狠狠色狠狠综合| 蜜臀精品一区二区三区在线观看| 精品国产123| 色婷婷亚洲综合| 蜜桃av噜噜一区二区三区小说| 久久久久国产精品麻豆| 欧美三级一区二区| 日韩国产欧美在线视频| 日韩女优av电影在线观看| 91在线小视频| 日韩vs国产vs欧美| 国产精品美女一区二区在线观看| 欧洲中文字幕精品| 国产麻豆成人传媒免费观看| 中文字幕制服丝袜成人av| 91精品欧美福利在线观看| 波多野结衣亚洲| 久久爱www久久做| 亚洲自拍偷拍图区| 久久在线观看免费| 在线区一区二视频| 国产99精品视频| 日本一区中文字幕| 亚洲欧美日韩人成在线播放| 精品99久久久久久| 欧美日高清视频| av电影在线观看一区| 男女男精品视频网| 国产精品毛片无遮挡高清| 欧美电影免费观看高清完整版在线| 91在线国产福利| 国产在线不卡一卡二卡三卡四卡| 亚洲成人综合视频| 亚洲激情在线激情| 国产精品久久久99| 久久久另类综合| 欧美mv和日韩mv的网站| 欧美色网站导航| 国产99久久久久| 久久er99热精品一区二区| 亚洲欧洲制服丝袜| 国产精品亲子乱子伦xxxx裸| 欧美va亚洲va香蕉在线| 欧美日韩国产综合一区二区三区| 91香蕉国产在线观看软件| 国产成人a级片| 国产在线精品免费| 国内精品伊人久久久久av一坑| 亚洲不卡一区二区三区| 玉米视频成人免费看| 国产精品天美传媒沈樵| 国产精品视频免费| 亚洲国产精品国自产拍av| 国产人妖乱国产精品人妖| 午夜在线成人av| 日韩精品一二三四| 日本色综合中文字幕| 日韩av在线免费观看不卡| 亚洲一区二区三区国产| 日韩在线a电影| 亚洲图片欧美色图| 男女性色大片免费观看一区二区| 美女视频第一区二区三区免费观看网站 | 国产剧情一区二区| 国产麻豆精品在线观看| 国产一区在线不卡| 色综合久久六月婷婷中文字幕| 99久久精品一区二区| 欧美综合亚洲图片综合区| 欧美一区二区三区免费| 欧美成人精品福利| 国产亚洲福利社区一区| 国产精品水嫩水嫩| 精品国产一区二区三区久久久蜜月 | 免费在线观看日韩欧美| 免费成人在线网站| 东方欧美亚洲色图在线| 国产一区二区调教| av激情综合网| 欧美日韩aaaaaa| 精品黑人一区二区三区久久| 久久精品一区蜜桃臀影院| 亚洲欧美综合另类在线卡通| 一区二区三区四区乱视频| 午夜视频在线观看一区二区三区| 日本中文字幕一区| 丰满放荡岳乱妇91ww| 91国产丝袜在线播放| 欧美一级夜夜爽| 欧美国产亚洲另类动漫| 玉足女爽爽91| 久久99国产精品久久| 懂色av噜噜一区二区三区av| 99精品黄色片免费大全| 欧美喷潮久久久xxxxx| 久久这里都是精品| 亚洲国产wwwccc36天堂| 国产高清不卡一区二区| 在线观看免费一区| 精品成人免费观看| 一区二区在线免费观看| 久久国产精品免费| 91论坛在线播放| 欧美图区在线视频| 久久影院午夜论| 亚洲欧洲www| 首页亚洲欧美制服丝腿| 成人爱爱电影网址| 欧美日韩一区二区三区不卡| 久久综合色8888| 亚洲日本中文字幕区| 日本成人在线电影网| aaa欧美大片| 91精品一区二区三区在线观看| 国产欧美久久久精品影院| 婷婷亚洲久悠悠色悠在线播放| 欧美一级高清大全免费观看| 国产精品日日摸夜夜摸av| 欧美aa在线视频| 欧美麻豆精品久久久久久| 国产精品久久久久久福利一牛影视 | 狠狠久久亚洲欧美| 欧美日韩三级视频| 亚洲自拍与偷拍| 成人深夜福利app| 国产黄色成人av| 中文字幕av在线一区二区三区| 亚洲午夜日本在线观看| 亚洲精品一区在线观看| 精品视频在线免费| 粉嫩嫩av羞羞动漫久久久| 成人av动漫网站| 国产乱妇无码大片在线观看| 久久免费国产精品| 91精品一区二区三区久久久久久 | 日韩美女主播在线视频一区二区三区 | 一区二区三区毛片| 91一区二区三区在线观看| 亚洲欧美一区二区三区孕妇| 99精品国产91久久久久久| 亚洲精品免费视频| 欧美日韩一区二区三区四区五区 | 一区二区三区中文字幕电影| 在线视频中文字幕一区二区| 亚洲福利国产精品| 欧美电影免费观看高清完整版在| 国产精品18久久久久久久久| 久久久www成人免费无遮挡大片| 国产不卡视频在线观看| 亚洲欧美另类在线| 欧美电影在线免费观看| 精品一区二区三区视频| 国产精品女主播在线观看| 在线观看国产日韩| 麻豆91在线观看| 成人欧美一区二区三区小说| 欧美吻胸吃奶大尺度电影| 精品一区二区日韩|