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

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

?? ch17.htm

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

<P>

Notice that the end-of-line indicator is left as part of the record.

This behavior also happens when the newline is used as the end-of-line

indicator. You can use <TT>chop()</TT>

or <TT>chomp()</TT> to remove the

dash, if needed.

<H3><A NAME="ExampleUsingtheTTFONTSIZEFACECouriernFONTTTFONTSIZEandFONTTTFONTSIZEFACECourierpFONTTTFONTSIZEOptionsFONT">

Example: Using the <TT>-n</TT>

and </FONT><TT>-p</TT>

Options</FONT></A></H3>

<P>

The <TT>-n</TT> and <TT>-p</TT>

options wrap your script inside loops. Before looking at specific

examples, let's see what the loops look like and how they are

changed by the <TT>-a</TT> and <TT>-F</TT>

options.

<P>

The <TT>-n</TT> option causes Perl

to execute your script inside the following loop:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    # your script

}

</PRE>

</BLOCKQUOTE>

<P>

The <TT>-p</TT> option uses the same

loop, but adds a <TT>continue</TT>

block so that <TT>$_</TT> will be

printed every time through the loop. If both <TT>-n</TT>

and <TT>-p</TT> are specified on the

command line, the <TT>-p</TT> option

will take precedeNCe. The loop looks like this:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    # your script

} continue {

    print;

}

</PRE>

</BLOCKQUOTE>

<P>

The <TT>-a</TT> option adds a <TT>split()</TT>

fuNCtion call to the beginning of each iteration of the loop so

that the loop looks like this:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    @F = split(/ /);

    # your script

}

</PRE>

</BLOCKQUOTE>

<P>

The <TT>-F</TT> option lets you split

on something besides the space character. If you used <TT>-F/</TT>i<TT>+/</TT>

on the command line, the loop would look like this:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    @F = split(/i+/);

    # your script

}

</PRE>

</BLOCKQUOTE>

<P>

You can use <TT>BEGIN</TT> and <TT>END</TT>

blocks if you need to specify some initialization or cleanup code.

The initialization section might be used to create objects or

to open log files. The cleanup section can be used to display

statistics or close files. For example,

<BLOCKQUOTE>

<PRE>

BEGIN {

    # initialization section

    $count = 0;

}



while (&lt;&gt;) {

    # your script

}



END {

    # cleanup section

    print(&quot;The count was $count.\n&quot;);

}

</PRE>

</BLOCKQUOTE>

<P>

Next, you'll see some examples of these options in action. Let's

start with a command line that simply displays each line of the

input file-like the <TT>type</TT>

command in DOS and UNIX.

<BLOCKQUOTE>

<PRE>

perl -p -e &quot;1;&quot; test.dat

</PRE>

</BLOCKQUOTE>

<P>

This command line is equivalent to:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    1;

} continue {

    print;

}<BR>



</PRE>

</BLOCKQUOTE>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

The <TT>1;</TT> statement was used to give Perl something to process. Otherwise, Perl would not have had any statements to execute.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

And will display:

<BLOCKQUOTE>

<PRE>

David Veterinarian

John Orthopedist

Jeff Dentist

</PRE>

</BLOCKQUOTE>

<P>

How about just printing the first word of each line? You could

use this com-<BR>

mand line:

<BLOCKQUOTE>

<PRE>

perl -p -e &quot;s/\s*(\w+).*/$1/;&quot; test.dat

</PRE>

</BLOCKQUOTE>

<P>

which is equivalent to:

<BLOCKQUOTE>

<PRE>

while (&lt;&gt;) {

    s/\s*(\w+).*/$1/;

} continue {

    print;

}

</PRE>

</BLOCKQUOTE>

<P>

And will display:

<BLOCKQUOTE>

<PRE>

David

John

Jeff

</PRE>

</BLOCKQUOTE>

<P>

If you have data files that store information in columns, you

can pull out the second column of information like this:

<BLOCKQUOTE>

<PRE>

perl -p -e &quot;s/\s*.+\s(.+)\s*/$1\n/;&quot; test.dat

</PRE>

</BLOCKQUOTE>

<P>

which will display:

<BLOCKQUOTE>

<PRE>

Veterinarian

Orthopedist

Dentist

</PRE>

</BLOCKQUOTE>

<P>

You can use the <TT>-a</TT> option

to get access to information stored in columns. For example, you

could also display the second column like this:

<BLOCKQUOTE>

<PRE>

perl -p -a -e &quot;$_ = \&quot;$F[1]\n\&quot;;&quot; test.dat

</PRE>

</BLOCKQUOTE>

<P>

which is equivalent to

<BLOCKQUOTE>

<PRE>

 while (&lt;&gt;) {

    @F = split(/ /);

    $_ = \&quot;$F[1]\n\&quot;;

} continue {

    print;

}

</PRE>

</BLOCKQUOTE>

<P>

Notice that you need to escape the double-quotes in the above

command line. If you don't do this you will get an error message.

<H3><A NAME="ExampleUsingtheTTFONTSIZEFACECourieriFONTTTFONTSIZEOptionFONT">

Example: Using the <TT>-i</TT>

Option</FONT></A></H3>

<P>

The <TT>-i</TT> option lets you modify

files in-place. This means that Perl will automatically rename

the input file and open the output file using the original name.

You can force Perl to create a backup file by specifying a file

extension for the backup file immediately after the <TT>-i</TT>.

For example, <TT>-i.bak</TT>. If no

extension is specified, no backup file will be kept.

<P>

One of the more popular uses for the <TT>-i</TT>

option is to change sequeNCes of characters. This kind of change

normally requires 10 or more lines of code. However, using command-line

options you can do it like this:

<BLOCKQUOTE>

<PRE>

perl -p -i.bak -e &quot;s/harry/tom/g;&quot; test.dat

</PRE>

</BLOCKQUOTE>

<P>

This command-line will change all occurreNCes of &quot;harry&quot;

to &quot;tom&quot; in the <TT>test.dat</TT>

file.

<H3><A NAME="ExampleUsingtheTTFONTSIZEFACECouriersFONTTTFONTSIZEOptionFONT">

Example: Using the <TT>-s</TT>

Option</FONT></A></H3>

<P>

The <TT>-s</TT> option lets you create

your own custom switches. Custom switches are placed after the

script name but before any filename arguments. Any custom switches

are removed from the <TT>@ARGV</TT>

array. Then a scalar variable is named after the switch is created

and initialized to 1. For example, let's say that you want to

use a switch called <TT>-useTR</TT>

in a script like the one in Listing 17.3.

<HR>

<BLOCKQUOTE>

<B>Listing 17.3&nbsp;&nbsp;17LST03.PL-Checking for the </B><TT><B><FONT FACE="Courier">useTR</FONT></B></TT><B>

Switch<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

if ($useTR) {

    # do TR processing.

    print &quot;useTR=$useTR\n&quot;;

}

</PRE>

</BLOCKQUOTE>

<HR>

<P>

You might execute this program using this following command line:

<BLOCKQUOTE>

<PRE>

perl -s -w 17lst03.pl -useTR

</PRE>

</BLOCKQUOTE>

<P>

and it would display:

<BLOCKQUOTE>

<PRE>

useTR=1

</PRE>

</BLOCKQUOTE>

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

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

<P>

This chapter covered the different command-line options that you

can use with Perl. The options can also be referred to as switches

because they turn different behaviors on and off.

<P>

The switches can be specified on the command line or using the

#! line inside your script. If you use the #! line, try to place

the options after the 32<FONT SIZE=1>nd</FONT> position to avoid

iNConsistent handling by different versions of UNIX.

<P>

The <TT>-n</TT> option is used to

place your script inside of an input loop. The <TT>-p</TT>

option uses the same loop, but also prints the <TT>$_</TT>

variable after each pass through the loop. The <TT>-a</TT>

and <TT>-F</TT> options are used when

you want the input lines to be split into the <TT>@F</TT>

array.

<P>

Another very useful option is <TT>-i</TT>,

which lets you edit files in-place. This option is good when you

are doing a lot of text file manipulation.

<P>

The next chapter, &quot;Using Internet Protocols,&quot; introduces

you to some of the different standards used on the Internet. These

standards let you do activities like read mail, send mail, and

transfer files.

<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 is a command-line option?

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

<LI>What switch should always be used?

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

instead of the newline?

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

option?

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

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

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

</OL>

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

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

<OL>

<LI>Use the <TT>-v</TT> option to

see the patchlevel of your version of Perl.

<LI>Use the chomp or chop fuNCtion to remove the dash from the

end of the records printed by the program in Listing 17.2.

<LI>Write a program that uses the <TT>-p</TT>

option to display the third column.

<LI>Modify the program written in Exercise 3 to use a <TT>BEGIN</TT>

block to ask the user which column to display.

<LI>Create a sample e-mail message that contains a Perl script.

Use the <TT>-x</TT> option to execute

it.

<LI>Modify the e-mail message written for Exercise 5 to display

any text that appears after the <TT>__END__</TT>

token. Hint: Use the DATA file handle.

</OL>

<HR>



<CENTER><P><A HREF="ch16.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch16.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="ch18.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch18.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一区二区三区免费野_久草精品视频
欧美中文字幕一区二区三区| 亚洲精品一区二区三区在线观看| 在线亚洲一区二区| 日韩欧美国产电影| 精品国产百合女同互慰| 亚洲午夜三级在线| 欧美色中文字幕| 亚洲午夜久久久久久久久电影院 | 91精品91久久久中77777| 日韩欧美国产一区在线观看| 高清日韩电视剧大全免费| 久久精品99国产精品日本| 日韩电影在线观看一区| 日韩精品电影一区亚洲| 亚洲视频香蕉人妖| 一区二区在线观看视频 | 国产精品亚洲一区二区三区妖精| 极品少妇xxxx偷拍精品少妇| 国产精品亚洲一区二区三区在线 | 91在线观看地址| 在线免费精品视频| 精品久久久久久无| 国产精品婷婷午夜在线观看| 日日骚欧美日韩| 久久成人久久鬼色| 91片在线免费观看| 91精品国产一区二区三区| 久久久久久久久99精品| 亚洲影视在线播放| 国产伦精品一区二区三区免费迷| heyzo一本久久综合| 性欧美大战久久久久久久久| 国产一区二区三区日韩| 色综合网站在线| 亚洲人成网站影音先锋播放| 精品在线免费观看| 亚洲欧美国产毛片在线| 99国产一区二区三精品乱码| 欧美美女激情18p| 久久精品一区二区三区四区| 日韩国产欧美一区二区三区| 国产69精品久久777的优势| 91精品国产综合久久小美女| 亚洲九九爱视频| 国产成人综合精品三级| 日韩一区二区视频| 亚洲自拍另类综合| av成人老司机| 欧美视频在线一区二区三区 | 久久国产三级精品| 国产精品一二三| 色一情一伦一子一伦一区| 成人精品免费视频| 欧美一区二区三区四区久久| 国产免费成人在线视频| 国产精品视频观看| 国产福利一区二区三区| 欧美mv和日韩mv国产网站| 亚洲电影第三页| 色哟哟一区二区| 成人欧美一区二区三区小说 | 亚洲高清一区二区三区| 97se狠狠狠综合亚洲狠狠| 久久精品视频一区| 久久99国产精品久久| 欧美精品乱码久久久久久| 国产精品久久久久久久久免费丝袜| 久久99久久久欧美国产| 91麻豆精品国产自产在线| 亚洲国产视频在线| 欧美体内she精视频| 亚洲欧美日韩国产综合在线| 成人一区二区三区视频在线观看| 国产亚洲女人久久久久毛片| 国产资源精品在线观看| 久久久久久久电影| 极品尤物av久久免费看| 国产午夜亚洲精品午夜鲁丝片 | 精品污污网站免费看| 综合久久综合久久| 91在线国产福利| 国产精品欧美久久久久无广告 | 精品一区在线看| 亚洲精品国产第一综合99久久| 日韩欧美第一区| 欧洲另类一二三四区| 国产一区不卡视频| 日韩制服丝袜av| 亚洲蜜臀av乱码久久精品 | 欧美午夜理伦三级在线观看| 国产电影精品久久禁18| 五月天一区二区| 中文字幕亚洲成人| 久久久午夜电影| 欧美一区二视频| 在线视频欧美区| 99re视频精品| 国产大片一区二区| 另类综合日韩欧美亚洲| 亚洲午夜成aⅴ人片| 成人欧美一区二区三区黑人麻豆 | 国产精品你懂的| 久久先锋影音av鲁色资源网| 91精品啪在线观看国产60岁| 日本高清无吗v一区| 91小视频免费观看| 成人午夜激情影院| 国产精品一线二线三线| 毛片不卡一区二区| 天天综合日日夜夜精品| 亚洲一区在线观看免费| 一区二区三区免费在线观看| 综合久久一区二区三区| 中文字幕一区二区三区在线观看 | 久草这里只有精品视频| 日韩专区中文字幕一区二区| 亚洲午夜av在线| 一个色妞综合视频在线观看| 亚洲激情图片一区| 亚洲国产精品自拍| 亚洲三级在线观看| 亚洲欧美日韩国产一区二区三区 | 高清国产一区二区三区| 成人av电影在线观看| 国产精品久久久久天堂| 日韩视频免费观看高清在线视频| 成人少妇影院yyyy| 国产精品一区二区免费不卡| 亚洲久草在线视频| 日本一区二区三级电影在线观看| 国产精品一区二区久久精品爱涩| 最新国产の精品合集bt伙计| 国产亚洲欧美色| 欧美一区二区三区在线观看 | 自拍av一区二区三区| 91超碰这里只有精品国产| 97se亚洲国产综合自在线| 精品一区二区三区在线播放| 五月综合激情网| 亚洲综合一区在线| 亚洲一级二级在线| 亚洲免费观看高清在线观看| 欧美激情一区三区| 国产亚洲一区二区三区在线观看 | 男人操女人的视频在线观看欧美| 日韩二区在线观看| 成人在线一区二区三区| 日韩三级av在线播放| 亚洲综合色自拍一区| 成人丝袜视频网| 欧美日本高清视频在线观看| 日韩美女视频在线| 欧美一区二区三区播放老司机| 国产91精品欧美| 久久电影网电视剧免费观看| 国产在线视频精品一区| 国产精品夜夜嗨| 欧美成人一级视频| 91老师国产黑色丝袜在线| 日韩不卡一区二区| 不卡高清视频专区| 97久久精品人人做人人爽50路| 欧美日韩国产首页| 国产精品蜜臀在线观看| 国产一区二区三区不卡在线观看| 成人性生交大合| 在线成人av影院| 亚洲欧美在线另类| 蜜桃久久久久久| 99re6这里只有精品视频在线观看| 欧美巨大另类极品videosbest | 亚洲精选视频免费看| 日韩**一区毛片| 91在线观看一区二区| 日韩午夜激情免费电影| 亚洲综合色婷婷| 精品无人码麻豆乱码1区2区| 色乱码一区二区三区88| 欧美一区二区三区四区久久| 亚洲天堂久久久久久久| 偷拍与自拍一区| 欧美优质美女网站| 国产精品美女久久久久av爽李琼| 三级在线观看一区二区| 欧美网站一区二区| 日韩av网站在线观看| 欧美日韩免费观看一区三区| 国产精品大尺度| 丁香六月久久综合狠狠色| 欧美激情一区二区在线| 粉嫩欧美一区二区三区高清影视| 久久只精品国产| 成人一级视频在线观看| 欧美激情中文字幕| 北条麻妃一区二区三区| 国产欧美一区二区精品仙草咪| 国产伦理精品不卡| 成人免费在线播放视频| 欧美一级精品大片| 国产最新精品精品你懂的|