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

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

?? ch9.htm

?? prrl 5 programs codes in the book
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
This program displays:<BR>

<BLOCKQUOTE>

<PRE>

30 31 0d 0a

30 32 0d 0a

30 33 0d 0a

</PRE>

</BLOCKQUOTE>

<P>

When the file is read in binary mode, you can see that there are

really two characters at the end of every line-the linefeed and

newline characters.

<P>

Our next example will look at the end-of-file character in both

text and binary modes. We'll use a data file called <TT>EOF.DAT</TT>

with the following contents:

<BLOCKQUOTE>

<PRE>

01

02

&lt;end of file character&gt;03

</PRE>

</BLOCKQUOTE>

<P>

SiNCe the end-of-file character is a non-printing character, it

can't be shown directly. In the spot <TT>&lt;end

of file character&gt;</TT> above is really the value 26.

<P>

Here is the program that you saw previously read the BINARY.DAT

file, only this time, it will read EOF.DAT.

<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>Initialize a buffer variable.<BR>

Open the </I><TT><I>BINARY.DAT</I></TT><I>

file for reading.<BR>

Read the first 20 characters of the file using the </I><TT><I>read()</I></TT><I>

fuNCtion.<BR>

Close the file.<BR>

Create an array of out of the characters in the </I><TT><I>$buffer</I></TT><I>

variable and iterate over that array using a </I><TT><I>foreach</I></TT><I>

loop.<BR>

Print the value of the current array element in hexadecimal format.

<BR>

Print a newline character. The current array element is a newline

character.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 9.10&nbsp;&nbsp;09LST10.PL-Reading a File to Show the

Text Mode End-of-File Character<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$buffer = &quot;&quot;;



open(FILE, &quot;&lt;eof.dat&quot;);

read(FILE, $buffer, 20, 0);

close(FILE);



foreach (split(//, $buffer)) {

    printf(&quot;%02x &quot;, ord($_));

    print &quot;\n&quot; if $_ eq &quot;\n&quot;;

}

</PRE>

</BLOCKQUOTE>

<HR>

<P>

This program displays:

<BLOCKQUOTE>

<PRE>

30 31 0d 0a

30 32 0d 0a

</PRE>

</BLOCKQUOTE>

<P>

The end-of-file character prevents the read() fuNCtion from reading

the third line. If the file is placed into binary mode, the whole

file can be read.

<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>Initialize a buffer variable.<BR>

Open the </I><TT><I>BINARY.DAT</I></TT><I>

file for reading.<BR>

Change the mode to binary.<BR>

Read the first 20 characters of the file using the </I><TT><I>read()</I></TT><I>

fuNCtion.<BR>

Close the file.<BR>

Create an array of out of the characters in the </I><TT><I>$buffer</I></TT><I>

variable and iterate over that array using a </I><TT><I>foreach</I></TT><I>

loop.<BR>

Print the value of the current array element in hexadecimal format.

<BR>

Print a newline character. The current array element is a newline

character.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 9.11&nbsp;&nbsp;09LST11.PL-Reading a File to Show that

Binary Mode Does Not Recognize the End-of-File Character<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

$buffer = &quot;&quot;;



open(FILE, &quot;&lt;eof.dat&quot;);

binmode(FILE);

read(FILE, $buffer, 20, 0);

close(FILE);



foreach (split(//, $buffer)) {

    printf(&quot;%02x &quot;, ord($_));

    print &quot;\n&quot; if $_ eq &quot;\n&quot;;

}

</PRE>

</BLOCKQUOTE>

<HR>

<P>

This program displays:

<BLOCKQUOTE>

<PRE>

30 31 0d 0a

30 32 0d 0a

1a 30 33 0d 0a

</PRE>

</BLOCKQUOTE>

<P>

With binary mode on, bytes with a value of 26 have no special

meaning and the third line can be read. You see that the value

26-33 in hexadecimal-was printed along with the rest of the characters.

<P>

<TT>Example: Reading into a Hash</TT>

<P>

You've already seen that you can read a file directly into a regular

array using this syntax:

<BLOCKQUOTE>

<PRE>

@array = &lt;FILE_HANDLE&gt;;

</PRE>

</BLOCKQUOTE>

<P>

Unfortunately, there is no similar way to read an entire file

into a hash. But, it's still pretty easy to do. The following

example will use the line number as the hash key for each line

of a file.

<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>Open the </I><TT><I>FIXED.DAT</I></TT><I>

file for reading.<BR>

For each line of </I><TT><I>FIXED.DAT </I></TT><I>create

a hash element using the record number special variable (</I><TT><I>$.</I></TT><I>)

as the key and the line of input (</I><TT><I>$_</I></TT><I>)

as the value.<BR>

Close the file.<BR>

Iterate over the keys of the hash.<BR>

Print each key, value pair.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 9.12&nbsp;&nbsp;09LST12.PL-Reading a Fixed Length Record

with Fixed Length Fields into a Hash<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

open(FILE, &quot;&lt;fixed.dat&quot;);

while (&lt;FILE&gt;) {

    $hash{$.} = $_;

}

close(FILE);



foreach (keys %hash) {

    print(&quot;$_: $hash{$_}&quot;);

}

</PRE>

</BLOCKQUOTE>

<HR>

<P>

This program displays:<BR>

<BLOCKQUOTE>

<PRE>

1: 1212Jan       Jaspree             Painter

2: 3453Kelly     Horton              Jockey

</PRE>

</BLOCKQUOTE>

<H3><A NAME="ExampleGettingFileStatistics">

Example: Getting File Statistics</A></H3>

<P>

The file test operators can tell you a lot about a file, but sometimes

you need more. In those cases, you use the <TT>stat()</TT>

or <TT>lstat()</TT> fuNCtion. The

<TT>stat()</TT> returns file information

in a 13-element array. You can pass either a file handle or a

file name as the parameter. If the file can't be found or another

error occurs, the null list is returned. Listing 9.13 shows how

to use the <TT>stat()</TT> fuNCtion

to find out information about the <TT>EOF.DAT</TT>

file used earlier in the chapter.

<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 return list from the </I><TT><I>stat()</I></TT><I>

fuNCtion to 13 scalar variables.<BR>

Print the scalar values.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 9.13&nbsp;&nbsp;09LST13.PL-Using the </B><TT><I><B><FONT FACE="Courier">stat()</FONT></B></I></TT><B>

FuNCtion<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,

    $atime, $mtime, $ctime, $blksize, $blocks) = stat(&quot;eof.dat&quot;);



print(&quot;dev     = $dev\n&quot;);

print(&quot;ino     = $ino\n&quot;);

print(&quot;mode    = $mode\n&quot;);

print(&quot;nlink   = $nlink\n&quot;);

print(&quot;uid     = $uid\n&quot;);

print(&quot;gid     = $gid\n&quot;);

print(&quot;rdev    = $rdev\n&quot;);

print(&quot;size    = $size\n&quot;);

print(&quot;atime   = $atime\n&quot;);

print(&quot;mtime   = $mtime\n&quot;);

print(&quot;ctime   = $ctime\n&quot;);

print(&quot;blksize = $blksize\n&quot;);

print(&quot;blocks  = $blocks\n&quot;);

</PRE>

</BLOCKQUOTE>

<HR>

<P>

In the DOS environment, this program displays:

<BLOCKQUOTE>

<PRE>

dev     = 2

ino     = 0

mode    = 33206

nlink   = 1

uid     = 0

gid     = 0

rdev    = 2

size    = 13

atime   = 833137200

mtime   = 833195316

ctime   = 833194411

blksize =

blocks  =

</PRE>

</BLOCKQUOTE>

<P>

Some of this information is specific to the UNIX environment and

is beyond the scope of this book. For more information on this

topic, see Que's 1994 edition of <I>Using Unix</I>. One interesting

piece of information is the <TT>$mtime</TT>

value-the date and time of the last modification made to the file.

You can interpret this value by using the following line of code:

<BLOCKQUOTE>

<PRE>

($sec, $min, $hr, $day, $month, $year, $day_Of_Week, 

    $julianDate, $dst) = localtime($mtime);

</PRE>

</BLOCKQUOTE>

<P>

If you are only interested in the modification date, you can use

the array slice notation to just grab that value from the 13-element

array returned by <TT>stat()</TT>.

For example:

<BLOCKQUOTE>

<PRE>

$mtime = (stat(&quot;eof.dat&quot;))[9];

</PRE>

</BLOCKQUOTE>

<P>

Notice that the <TT>stat()</TT> fuNCtion

is surrounded by parentheses so that the return value is evaluated

in an array context. Then the tenth element is assigned to <TT>$mtime</TT>.

You can use this technique whenever a fuNCtion returns a list.

<H3><A NAME="ExampleUsingtheDirectoryFuNCtions">

Example: Using the Directory FuNCtions</A></H3>

<P>

Perl has several fuNCtions that let you work with directories.

You can make a directory with the <TT>mkdir()</TT>

fuNCtion. You can delete a directory with the <TT>rmdir()</TT>

fuNCtion. Switching from the current directory to another is done

using the <TT>chdir()</TT> fuNCtion.

<P>

Finding out which files are in a directory is done with the <TT>opendir()</TT>,

<TT>readdir()</TT>, and <TT>closedir()</TT>

fuNCtions. The next example will show you how to create a list

of all Perl programs in the current directory-well, at least those

files that end with the pl extension.

<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>Open the current directory using </I><TT><I>DIR</I></TT><I>

as the directory handle.<BR>

Read a list of file names using the </I><TT><I>readdir()</I></TT><I>

fuNCtion; extract only those that end in </I><TT><I>pl</I></TT><I>;

and the sorted list. The sorted list is assigned to the </I><TT><I>@files</I></TT><I>

array variable.<BR>

Close the directory.<BR>

Print the file names from the </I><TT><I>@files</I></TT><I>

array unless the file is a directory.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 9.14&nbsp;&nbsp;09LST14.PL-Print All Files in the Current

Directory Whose Name Ends in PL<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜电影小说| 久久精品在线观看| 国产午夜一区二区三区| 亚洲欧美成人一区二区三区| 久久99在线观看| 91黄色免费版| 国产精品视频免费看| 日本中文字幕不卡| 欧美午夜电影网| 国产精品久久久久影院老司 | 在线成人免费观看| 国产精品久久久久久户外露出 | 国产成人免费在线观看| 91精品国产入口| 亚洲最新在线观看| eeuss鲁片一区二区三区| 久久久三级国产网站| 欧美a级理论片| 777久久久精品| 亚洲一区二区av电影| 色综合天天综合网国产成人综合天 | 欧美唯美清纯偷拍| 亚洲欧美偷拍三级| 成人理论电影网| 国产日韩欧美高清在线| 国产原创一区二区三区| 久久综合久久鬼色| 韩国av一区二区三区四区| 日韩一区二区中文字幕| 青青草伊人久久| 精品久久国产字幕高潮| 久久99蜜桃精品| 精品国产成人在线影院| 久久66热re国产| 精品粉嫩aⅴ一区二区三区四区| 麻豆成人久久精品二区三区小说| 69堂国产成人免费视频| 日本色综合中文字幕| 欧美一区二区三区视频在线| 蜜桃av一区二区| 亚洲精品在线观| 国产成人综合亚洲网站| 中文字幕av一区二区三区免费看| 成人午夜免费av| 亚洲日本免费电影| 在线观看一区二区视频| 亚洲第一二三四区| 日韩欧美在线1卡| 国内精品久久久久影院色 | 欧美麻豆精品久久久久久| 午夜久久久久久电影| 91精品国产综合久久福利 | 日本美女一区二区三区视频| 日韩欧美的一区二区| 国产成人精品免费视频网站| 最新国产成人在线观看| 欧美日韩国产精品自在自线| 裸体歌舞表演一区二区| 国产精品久久久久久亚洲毛片| 91国产免费看| 蜜桃久久久久久久| 中文字幕一区在线观看| 欧美精选午夜久久久乱码6080| 久久91精品久久久久久秒播| 国产精品二三区| 日韩一级片在线观看| 国产白丝精品91爽爽久久| ●精品国产综合乱码久久久久| 欧美日韩美女一区二区| 精品一区二区三区免费视频| 国产精品的网站| 欧美精品日韩一区| 成人在线视频一区| 午夜精品久久久久| 久久九九影视网| 欧美性生交片4| 成人一区二区三区视频| 日韩中文字幕91| 国产精品久久久久aaaa樱花| 欧美一区二区黄色| 99re8在线精品视频免费播放| 日韩av电影免费观看高清完整版| 中文字幕制服丝袜成人av| 欧美一区二区三区的| 91最新地址在线播放| 狠狠色丁香婷综合久久| 亚洲一区二区在线观看视频 | 国产精品一区免费视频| 亚洲va中文字幕| 国产精品日日摸夜夜摸av| 日韩欧美国产午夜精品| 欧美午夜精品久久久| 99视频精品在线| 丁香桃色午夜亚洲一区二区三区| 奇米一区二区三区av| 一区二区三区视频在线观看| 日本一区二区高清| 国产女人aaa级久久久级| 日韩精品一区二区在线| 欧美一级久久久久久久大片| 欧美亚洲禁片免费| 91论坛在线播放| 波多野结衣欧美| 成人三级伦理片| 国产成人免费av在线| 激情国产一区二区| 久久精品国产亚洲aⅴ| 日本大胆欧美人术艺术动态| 亚洲成人免费视| 亚洲电影欧美电影有声小说| 亚洲自拍都市欧美小说| 一区二区三区成人| 亚洲风情在线资源站| 洋洋av久久久久久久一区| 亚洲综合成人在线视频| 亚洲国产视频网站| 亚洲1区2区3区4区| 美女网站色91| 国产一区二区在线观看视频| 美女性感视频久久| 国产麻豆成人传媒免费观看| 国产乱一区二区| 丰满白嫩尤物一区二区| 成人av在线网| 日本精品免费观看高清观看| 欧美日韩免费视频| 欧美成人三级在线| 国产日韩欧美精品电影三级在线 | 2017欧美狠狠色| 亚洲国产精品99久久久久久久久 | 国产日韩欧美在线一区| 亚洲视频在线观看一区| 亚洲制服丝袜在线| 免费成人av资源网| 国产成人精品亚洲日本在线桃色| 成人午夜碰碰视频| 欧美久久一区二区| 精品福利在线导航| 一区在线播放视频| 午夜电影网一区| 精品一区二区三区久久| 成人污视频在线观看| 欧美三级视频在线观看| ww久久中文字幕| 自拍av一区二区三区| 蜜桃av一区二区三区电影| 成人黄色免费短视频| 欧美色国产精品| 久久久精品免费免费| 亚洲国产视频a| 国产成人亚洲精品狼色在线| 91国模大尺度私拍在线视频| 久久人人超碰精品| 亚洲综合一区二区精品导航| 韩日精品视频一区| 欧美色电影在线| 欧美韩国一区二区| 蜜桃视频一区二区| 91福利国产成人精品照片| 欧美大黄免费观看| 亚洲国产精品自拍| 成人高清视频免费观看| 91精品国产一区二区人妖| 亚洲人成人一区二区在线观看| 久久国产福利国产秒拍| 91高清视频在线| 国产日产欧美精品一区二区三区| 三级影片在线观看欧美日韩一区二区 | 在线观看成人小视频| 久久综合九色综合欧美98 | 亚洲免费资源在线播放| 精品一区二区三区在线播放视频| 欧美亚洲尤物久久| 亚洲欧美日韩久久精品| 成人美女视频在线看| 精品国产乱码久久久久久免费 | 亚洲小少妇裸体bbw| 成人小视频在线观看| 精品国产3级a| 久久av中文字幕片| 欧美一区二区不卡视频| 亚洲国产视频一区| 91久久精品日日躁夜夜躁欧美| 日本一区二区免费在线观看视频 | 91浏览器入口在线观看| 久久男人中文字幕资源站| 日韩综合小视频| 欧美另类一区二区三区| 亚洲午夜久久久久| 欧美在线观看视频一区二区三区| 亚洲欧洲美洲综合色网| 成人97人人超碰人人99| 久久伊人蜜桃av一区二区| 精品一区二区三区不卡 | 国产成人高清在线| 久久你懂得1024| 国产精品一区二区三区乱码| 久久久不卡影院| 国产福利一区在线| 国产日韩欧美高清|