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

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

?? ch3.htm

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

<P>

Now it's time to look at associative arrays. These are definitely

the most complicated of the three data types. And yet, they are

just another type of array. You've already seen that array elements

can be accessed with both positive and negative integer indexes.

Well, with associative arrays you can use <I>any</I> scalar data

type as an index. Associative array names start with the <TT>%</TT>

character.

<P>

You will see associative arrays called <I>hashes </I>at times.

The term &quot;hash&quot; refers to how associative array elements

are stored in memory. &quot;Hash&quot; also is much shorter than

&quot;associative array,&quot; and therefore much easier to type

and talk about.

<H3><A NAME="ExampleAssigningValuestoAssociativeArrayVariables">

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

<P>

Before we discuss associative arrays further, let's see how to

assign values to them. When defining a whole array, you can use

the same representation that was used for arrays-just remember

that you need two items for every element in the associative array.

You also can assign values to individual elements of an associative

array by using curly braces (<TT>{}</TT>)

around the index key.

<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>Create an associative array with three elements. Each element

consists of twovalues: the lookup key and its associated value.

<BR>

Add a single element to the associative array.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

%associativeArray = (&quot;Jack A.&quot;, &quot;Dec 2&quot;, &quot;Joe B.&quot;,

    &quot;June 2&quot;, &quot;Jane C.&quot;, &quot;Feb 13&quot;);

$associativeArray{&quot;Jennifer S.&quot;} = &quot;Mar 20&quot;;



print &quot;Joe's birthday is: &quot; . $associativeArray{&quot;Joe B.&quot;} . &quot;\n&quot;;

print &quot;Jennifer's birthday is: &quot; . $associativeArray{&quot;Jennifer S.&quot;} . &quot;\n&quot;;

</PRE>

</BLOCKQUOTE>

<P>

This program will print the following:

<BLOCKQUOTE>

<PRE>

Joe's birthday is: June 2

Jennifer's birthday is: Mar 20

</PRE>

</BLOCKQUOTE>

<P>

Perl will extend the associative array as needed when you assign

values to keys. An internal table is used to keep track of which

keys are defined. If you try to access an undefined key, Perl

will return a null or blank string.

<P>

You can do a lot with associative arrays, but first you need more

background in operators, fuNCtions, and statements. We'll handle

these topics in future chapters. In the next section, we look

at string literals and how they interact with variables.

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

Double-Quoted Strings Revisited</FONT></A></H2>

<P>

Perl strings have some additional fuNCtionality that was not mentioned

in <A HREF="ch1.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch1.htm" >Chapter 1</A> &quot;Getting Your Feet Wet,&quot; because you needed

to know a little about variables beforehand. Now that you are

familiar with how Perl handles basic variables, let's look a little

deeper at double-quoted strings.

<H3><A NAME="ExampleVariableInterpolation">

Example: Variable Interpolation</A></H3>

<P>

<I>Interpolation</I> is a big word for a simple coNCept-replacement

of a variable name with its value.You already know that variable

names are a &quot;stand-in&quot; for a value. If <TT>$var</TT>

is equal to <TT>10</TT>, the <TT>$var</TT>

+ <TT>20</TT> is really <TT>10

+ 20</TT>. In Perl, this coNCept also is used inside strings.

You can combine variables and strings in a very natural way using

Perl. Simply place the variable directly inside a double-quoted

string, and its value automatically will be interpolated as needed.

<BR>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

Until now, each time you printed an array, all of the elements were mashed together (coNCatenated). Having the array element printed without delimiting spaces made determining the individual items very difficult. If, when printing, you eNClose the array 
in quotes, Perl automatically will separate the array elements with a space.</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<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>Create a five-element array.<BR>

Print the element with spaces between the elements.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

@array = (1..5);

print &quot;@array\n&quot;;

</PRE>

</BLOCKQUOTE>

<P>

This program will print:

<BLOCKQUOTE>

<PRE>

1 2 3 4 5

</PRE>

</BLOCKQUOTE>

<P>

 Perl runs into a problem when you want to use a variable and

then append some letters to the end. Let's illustrate this with

scalar variables.

<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 the value </I><TT><I>large</I></TT><I>

to a scalar variable.<BR>

Print a string with an embedded variable.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$word = &quot;large&quot;;

print &quot;He was a $wordr fellow.&quot;;

</PRE>

</BLOCKQUOTE>

<P>

This program will print:

<BLOCKQUOTE>

<PRE>

He was a fellow.

</PRE>

</BLOCKQUOTE>

<P>

In this example, Perl looks for the variable <TT>$wordr</TT>-obviously

not what I intended to do. I meant for the string &quot;He was

a larger fellow&quot; to print. This problem can be corrected

by doing the following:

<BLOCKQUOTE>

<PRE>

$word = &quot;large&quot;;

print &quot;He was a &quot; . $word . &quot;r fellow.&quot;;

</PRE>

</BLOCKQUOTE>

<P>

Because the variable is separate, Perl sees the correct variable

name. Then the string coNCatenation operator joins the three strings

together. This method of programming makes it very easy to see

where the variable is.

<P>

Remember when I said that Perl enables you to do something in

many different ways? You also could do the following:

<BLOCKQUOTE>

<PRE>

print &quot;He was a ${word}r fellow.&quot;;

</PRE>

</BLOCKQUOTE>

<P>

The curly braces around the variable name tell Perl where the

name starts and ends.<BR>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

If you're ever on IRC and see <TT><B><FONT FACE="Courier">longhair_</FONT></B></TT> or Kirby Hughes (<TT><B><FONT FACE="Courier">khughes@netcom.com</FONT></B></TT>), tell him I said &quot;thanks.&quot; He remembered that curly braces can be used in this 
manner.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<H3><A NAME="ExampleUsingtheIquotISpecialVariable">

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

<P>

Perl has a number of special variables. These variables each have

a predefined meaning. <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;

introduces you to quite a few Perl special variables. However,

because we were just looking at strings and arrays, we also should

spend a moment and talk about the <TT>$&quot;</TT>

special variable.

<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>Set the </I><TT><I>$</I></TT><I>&quot;

special variable to the comma character.<BR>

Create a five-element array.<BR>

Print the element with commas between the elements.</I>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$&quot; = &quot;,&quot;;

@array = (1..5);

print &quot;@array\n&quot;;

</PRE>

</BLOCKQUOTE>

<P>

This program will print:

<BLOCKQUOTE>

<PRE>

1,2,3,4,5

</PRE>

</BLOCKQUOTE>

<P>

Of course, because <TT>$&quot;</TT>

is a scalar variable you also could assign a longer string to

it. For instaNCe, you could use <TT>$&quot;

= &quot;, &quot;</TT> to add both a comma and a space between

the array elements.

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

Summary</FONT></A></H2>

<P>

This chapter introduced you to the coNCept of variables-places

in computer memory that are used to hold values as your program

runs. They are called variables because you can assign different

values to them as needed.

<P>

You read about three types of variables: scalars, arrays, and

associative arrays. Each variable type has its own unique character

that is used to begin a variable name. Scalars use a <TT>$</TT>,

Arrays use an <TT>@</TT>, and associative

arrays use a <TT>%</TT>.<BR>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

When I first started to learn Perl, I found it difficult to remember which character begins which variable type. Then, I saw this chart on the Internet and things became clearer:</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>$ = &quot;the&quot; (singular)<BR>

@ = &quot;those&quot; (plural)<BR>

% = &quot;relationship&quot;</TT>

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

Each variable type must start with a different character that

uses a separate namespace. This means that <TT>$varName</TT>

and <TT>@varName</TT> are different

variables. Remember, too, that variable names in Perl are case-sensitive.

<P>

A lot of this chapter looked at assigning values to variables

using the equals (=) sign. We also reviewed how to use positive

and negative subscripts (such as <TT>$array[1]</TT>)

to access array elements. Associative array elements are accessed

a little differently-curly braces are used instead of square braces

(for example, <TT>$associativeArray{&quot;Jack

B.&quot;}</TT>).

<P>

And finally, we took another look at double-quoted strings to

see how variable interpolation works. You saw that Perl automatically

replaces variables inside double-quoted strings. When arrays are

printed inside strings, their elements are separated by the value

of <TT>$&quot;</TT>-which is usually

a space.

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

Review Questions</FONT></A></H2>

<P>

Answers to Review Questions are in Appendix A.

<OL>

<LI>What are the three basic data types that Perl uses?

<LI>How can you determine the number of elements in an array?

<LI>What is a namespace?

<LI>What is the special variable <TT>$[</TT>

used for?

<LI>What is the special variable <TT>$&quot;</TT>

used for?

<LI>What is the value of a variable when it is first used?

<LI>What is an associative array?

<LI>How can you access associative array elements?

</OL>

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

Review Exercises</FONT></A></H2>

<OL>

<LI>Create an array called <TT>@months</TT>.

It should have 12 elements in it with the names of the months

represented as strings.

<LI>Create a string that interpolates that value of the variable

<TT>$numberOfBooks</TT>.

<LI>Using the range operator (..), create an array with the following

elements: 1, 5, 6, 7, 10, 11, 12.

<LI>Using the array created in the last exercise, create a <TT>print</TT>

command to display the last element.

<LI>Create an associative array that holds a list of five music

artists and a rating for them. Use &quot;good,&quot; &quot;bad,&quot;

and &quot;indifferent&quot; as the ratings.

<LI>Using the array created in the last exercise, create a <TT>print</TT>

command to display the last element.

</OL>

<HR>



<CENTER><P><A HREF="ch2.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch2.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="ch4.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch4.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 + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久99精品久久| 亚洲1区2区3区视频| 亚洲三级视频在线观看| 日韩不卡免费视频| 成人激情免费视频| 日韩一区二区三区视频在线 | 成人av在线看| 欧美一级二级三级蜜桃| 一区二区三区电影在线播| 国产精品99久久久久久有的能看 | 亚洲成a人在线观看| 成人av资源在线观看| 精品捆绑美女sm三区| 丝瓜av网站精品一区二区| 91丨porny丨户外露出| 久久久久亚洲蜜桃| 蜜桃在线一区二区三区| 欧美图区在线视频| 一区二区在线观看视频| 成人av网址在线| 国产喂奶挤奶一区二区三区| 美女网站色91| 91麻豆精品国产| 视频一区视频二区中文字幕| 欧美三区在线观看| 亚洲一二三区不卡| 欧美综合色免费| 亚洲一区二区四区蜜桃| 日本韩国一区二区三区| 亚洲人成在线观看一区二区| 99riav一区二区三区| 中文字幕第一页久久| 成人永久aaa| 综合久久久久久久| 91免费版pro下载短视频| 亚洲视频免费在线观看| 91首页免费视频| 亚洲国产精品天堂| 91精品国产麻豆国产自产在线| 亚洲成人1区2区| 欧美精品乱人伦久久久久久| 日本美女一区二区| 国产欧美一区二区三区在线老狼| 国产精品影音先锋| 国产精品久久久久婷婷 | 国产高清在线精品| 日本一区二区免费在线观看视频| 国产成人在线观看| 亚洲免费观看在线视频| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 亚洲影视资源网| 在线不卡一区二区| 蜜桃精品视频在线| 日本一区二区免费在线| 一本色道久久综合亚洲91 | 久久精品72免费观看| 精品欧美一区二区在线观看| 国产精品夜夜爽| 一区二区在线观看av| 欧美精品 日韩| 男男成人高潮片免费网站| 久久欧美中文字幕| bt7086福利一区国产| 香蕉乱码成人久久天堂爱免费| 日韩三级在线观看| 成人h动漫精品一区二区 | 亚洲三级在线观看| 欧美一区二区成人6969| 国产麻豆精品一区二区| 亚洲精品高清在线观看| 日韩欧美一级在线播放| 波多野结衣一区二区三区 | 一区二区高清免费观看影视大全 | 中文字幕精品—区二区四季| 欧美日本视频在线| 国产91精品久久久久久久网曝门| 一区二区三区精品在线观看| 欧美不卡一区二区三区| 99国产精品视频免费观看| 日韩电影一区二区三区| 国产精品萝li| 日韩三级在线观看| 91亚洲国产成人精品一区二区三| 免费观看久久久4p| 综合久久久久久久| 国产人成亚洲第一网站在线播放| 欧美日韩在线精品一区二区三区激情| 精品中文字幕一区二区| 一区av在线播放| 国产日韩高清在线| 欧美一区二区成人6969| 在线国产亚洲欧美| 成人午夜免费av| 国产在线不卡一区| 天天爽夜夜爽夜夜爽精品视频| 国产精品―色哟哟| 精品日产卡一卡二卡麻豆| 欧美猛男超大videosgay| 色欲综合视频天天天| 国产福利91精品| 韩国女主播一区| 日韩精彩视频在线观看| 亚洲电影一级黄| 亚洲人成网站精品片在线观看| 国产欧美精品区一区二区三区| 日韩视频免费观看高清完整版在线观看 | 欧美一级专区免费大片| 欧美日韩美少妇| 日本道精品一区二区三区| a亚洲天堂av| 99在线精品视频| 波多野结衣中文一区| 国产精品 日产精品 欧美精品| 极品少妇xxxx精品少妇| 久久精品国产一区二区| 免费在线观看精品| 蜜桃一区二区三区四区| 免费高清视频精品| 久久99精品久久久久婷婷| 日韩黄色小视频| 男女男精品网站| 国产精品一区二区91| 国产大陆精品国产| 高清在线观看日韩| 波多野结衣中文字幕一区| 北条麻妃国产九九精品视频| 97se亚洲国产综合自在线观| 91在线国产观看| 色噜噜狠狠一区二区三区果冻| 91香蕉视频mp4| 在线视频综合导航| 欧美美女一区二区三区| 4438x亚洲最大成人网| 日韩午夜在线影院| 亚洲精品一区二区三区蜜桃下载 | 精品视频1区2区3区| 欧美一区二区三区啪啪| 精品久久久久久最新网址| 久久九九久久九九| 成人欧美一区二区三区白人 | 成人综合日日夜夜| 色8久久人人97超碰香蕉987| 色婷婷精品大在线视频| 欧美日韩精品综合在线| 日韩精品最新网址| 国产精品看片你懂得| 亚洲私人黄色宅男| 婷婷成人综合网| 国产在线不卡一区| 色爱区综合激月婷婷| 欧美变态口味重另类| 中文字幕av一区二区三区| 一二三四社区欧美黄| 老司机免费视频一区二区三区| 国产伦精一区二区三区| 欧美在线观看禁18| 精品国产凹凸成av人导航| 国产精品国产三级国产aⅴ入口 | 欧美一区二区三区啪啪| 日韩精品一区二区三区在线 | 蜜臀久久久99精品久久久久久| 精品无人码麻豆乱码1区2区| 国产精品久久久久一区二区三区 | 日韩不卡一二三区| 欧美日韩国产免费一区二区| 一区二区三区免费看视频| 97精品久久久久中文字幕| 国产精品久久午夜| 成人黄色软件下载| 欧美国产欧美综合| 成人综合日日夜夜| 中文字幕中文乱码欧美一区二区| 国产99一区视频免费| 欧美国产欧美综合| 不卡一区二区中文字幕| 国产精品每日更新在线播放网址| 成人午夜视频福利| 亚洲欧洲中文日韩久久av乱码| av亚洲产国偷v产偷v自拍| 中文字幕一区二区三区乱码在线| 成人一级片网址| 亚洲麻豆国产自偷在线| 在线观看网站黄不卡| 亚洲成va人在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 国产精品久久久久影视| 色综合久久88色综合天天 | 老司机一区二区| 久久久久久97三级| 99久久国产综合精品色伊| 一区二区三区在线免费播放| 欧美在线观看视频一区二区三区| 日韩国产精品久久久| 欧美成人精品高清在线播放| 国产精品一区在线观看乱码| 国产精品久99| 欧美精品九九99久久| 紧缚奴在线一区二区三区| 国产精品久久久久影院亚瑟| 欧美日韩中文一区|