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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch13.htm

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

<PRE>

^C at test.pl line 22

</PRE>

</BLOCKQUOTE>

<P>

Of course, the filename and line number change to match the particulars

of whatever script happens to be running when Ctrl+C was pressed.

The <TT>^C</TT> notation refers to

the Ctrl+C key sequeNCe.

<H3><A NAME="ExampleHowtoHandleaSignal">

Example: How to Handle a Signal</A></H3>

<P>

You can cause Perl to ignore the Ctrl+C key sequeNCe by placing

the following line of code near the beginning of your program:

<BLOCKQUOTE>

<PRE>

$SIG{'INT'} = 'IGNORE';

</PRE>

</BLOCKQUOTE>

<P>

You can restore the default handler like this:

<BLOCKQUOTE>

<PRE>

$SIG{'INT'} = 'DEFAULT';

</PRE>

</BLOCKQUOTE>

<P>

If you need to ensure that files are closed, error messages are

written, or other cleanup chores are completed, you need to create

a custom <TT>INT</TT> handle fuNCtion.

For example:

<BLOCKQUOTE>

<PRE>

sub INT_handler {

    # close all files.

    # send error message to log file.

    exit(0);

}



$SIG{'INT'} = 'INT_handler';

</PRE>

</BLOCKQUOTE>

<P>

If the Ctrl+C key sequeNCe is pressed anytime after the hash assignment

is made, the <TT>INT_handler</TT>

fuNCtion is called instead of the default handler.<BR>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

In theory, you could remove the <TT>exit()</TT> call from the signal handler fuNCtion, and the script should start executing from wherever it left off. However, this feature is not working on several platforms. If you want to test your platform, run the 
following small program:

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>sub INT_handler {<BR>

&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;Don't Interrupt!\n&quot;);<BR>

}<BR>

<BR>

$SIG{'INT'} = 'INT_handler';<BR>

for ($x = 0; $x &lt; 10; $x++) {<BR>

&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;$x\n&quot;);<BR>

&nbsp;&nbsp;&nbsp;&nbsp;sleep 1;<BR>

}</TT>

</BLOCKQUOTE>

<BLOCKQUOTE>

You should be able to press Ctrl+C while the script is counting without forcing the script to end.</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

The <TT>%SIG</TT> associative array

holds only entries you have created for your custom signal handler

fuNCtions. So, unfortunately, you can't find out which signals

are supported by looking at the array returned by <TT><I>keys</FONT></I><FONT FACE="Courier">(%SIG)</TT>.

<BR>

<p>

<CENTER>

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

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

<TR><TD>

<BLOCKQUOTE>

If you are running Perl on a UNIX machine, you can run the <TT>kill -l</TT> command. This command displays a list of possible signals.

</BLOCKQUOTE>



</TD></TR>

</TABLE>

</CENTER>

<P>

<P>

I looked directly into the perl.exe file supplied with my Perl

distribution to find out that the hip port of Perl for Win32 supports

the following signals:

<BLOCKQUOTE>

<TT>ABRT2</TT>-This signal means that

another process is trying to abort your process.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>BREAK2</TT>-This signal indicates

that a Ctrl+Break key sequeNCe was pressed under Windows.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>TERM2</TT>-This signal means that

another process is trying to terminate your process.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>SEGV2</TT>-This signal indicates

that a segment violation has taken place.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>FPE2</TT>-This signal catches

floating point exceptions.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>ILL2</TT>-This signal indicates

that an illegal instruction has been attempted.

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT>INT2</TT>-This signal indicates

that a Ctrl+C key sequeNCe was pressed under Windows.

</BLOCKQUOTE>

<P>

You can also use the <TT>%SIG</TT>

hash to trap a call to the <TT>warn()</TT>

and <TT>die()</TT> fuNCtions. This

comes in handy if you're working with someone else's code and

want to keep a log of whenever these fuNCtions are called. Rather

than finding every place the fuNCtions are used, you can define

a handler fuNCtion as in Listing 13.4.

<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>Define a handler for the </I><TT><I>warn()</I></TT><I>

fuNCtion. The error message is passed to the handler as the first

element of the </I><TT><I>@_ array</I></TT><I>.

<BR>

Define a handler for the </I><TT><I>die()</I></TT><I>

fuNCtion.<BR>

Define the </I><TT><I>sendToLogfile()</I></TT><I>

utility fuNCtion.<BR>

Start the signal catching by creating two entries in the </I><TT><I>%SIG</I></TT><I>

hash.<BR>

Invoke the </I><TT><I>warn()</I></TT><I>

and </I><TT><I>die()</I></TT><I> fuNCtions.</I>

</BLOCKQUOTE>

<HR>

<BLOCKQUOTE>

<B>Listing 13.4&nbsp;&nbsp;13LST04.PL-How to Define Signal Handler

FuNCtions for the </B><TT><I><B><FONT FACE="Courier">warn()</FONT></B></I></TT><B>

and </B><TT><I><B><FONT FACE="Courier">die() </FONT></B></I></TT><B>FuNCtions

<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<PRE>

sub WARN_handler {

    my($signal) = @_;

    sendToLogfile(&quot;WARN: $signal&quot;);

}



sub DIE_handler {

    my($signal) = @_;

    sendToLogfile(&quot;DIE: $signal&quot;);

}



sub sendToLogfile {

    my(@array) = @_;

    open(LOGFILE, &quot;&gt;&gt;program.log&quot;);

    print LOGFILE (@array);

    close(LOGFILE);

}



$SIG{__WARN__} = 'WARN_handler';

$SIG{__DIE__}  = 'DIE_handler';



chdir('/printer') or warn($!);

chdir('/printer') or die($!);

</PRE>

</BLOCKQUOTE>

<HR>

<P>

When this program is done executing, the <TT>PROGRAM.LOG</TT>

file contains these lines:

<BLOCKQUOTE>

<PRE>

WARN: No such file or directory at 13lst02.pl line 22.

DIE: No such file or directory at 13lst02.pl line 23.

</PRE>

</BLOCKQUOTE>

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

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

<P>

Your program's capability to handle error conditions that may

arise will determine, to a certain extent, how usable your program

is. If a user of your program finds that it stops working with

no error messages and, therefore, no way to solve whatever problem

has arisen, then your program won't be used for long.

<P>

Displaying error messages is also valuable during the programming

and debugging stage. If you mistakenly type a directory name,

it may take you an hour to look through the script and find the

problem. Handling the <TT>No such directory</TT>

error correctly in the first place will tell you what the problem

is and which line of the script has the problem.

<P>

In this chapter, you saw that checking for errors usually means

looking at the return value of the fuNCtions that are called.

Some fuNCtions set the <TT>errno</TT>

variable while others simply return true or false. While the <TT>errno</TT>

variable does have a core set of values that are system independent,

it also has system-dependent values. Listing 13.1 showed you how

to display the error values applicable to your system.

<P>

Next, you read about the <TT>or</TT>

logical operator. This operator evaluates only the right operand

if the left is false. Therefore, it is useful when testing for

unsuccessful fuNCtions that return false upon failure.

<P>

The <TT>die()</TT> and <TT>warn()</TT>

fuNCtions are both used to display an error message. In addition,

the <TT>die()</TT> fuNCtion causes

the script to end.

<P>

Then, the <TT>eval()</TT> fuNCtion

was covered. It is used to execute Perl code in a protected environment

so that fatal errors will not end the script. Any error messages

that do arise will be placed into the <TT>$@</TT>

special variable. All variable value changes and fuNCtion definitions

affect the main program.

<P>

Lastly, the signals were covered. Signals are messages sent to

a process by the operating system. There is a wide range of signals,

and they differ depending on which operating system you are using.

The <TT>%SIG</TT> associative array

is used to set up your own signal handling fuNCtion.

<P>

The next chapter discusses object orientation. You learn the definition

of an object, how to create one, and how to derive new objects

from existing objects.

<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>Why is it important to check for errors?

<LI>How is the <TT>die()</TT> fuNCtion

different from the <TT>warn()</TT>

fuNCtion?

<LI>What is the meaning of the <TT>$!</TT>

special variable?

<LI>What does the <TT>eval()</TT>

fuNCtion do?

<LI>What is a signal?

<LI>What will the statement <TT>$SIG{'ABRT'}

= 'IGNORE'</TT> do?

<LI>Which signal is used to trap floating point exceptions?

</OL>

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

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

<OL>

<LI>Write a program that opens a file and uses the <TT>die()</TT>

fuNCtion if an error occurs.

<LI>Write a program that uses the <TT>warn()</TT>

fuNCtion if an existing file will be overwritten by an <TT>open()</TT>

statement.

<LI>List three situations where the <TT>warn()</TT>

fuNCtion could be used.

<LI>List three situations where the <TT>die()</TT>

fuNCtion could be used.

<LI>Modify the interactive Perl interpreter to print a version

number when the <TT>version</TT> custom

command is used.

<LI>Modify the interactive Perl interpreter to save all commands

entered into a log file. Add a timestamp to each log entry.

</OL>

<HR>



<CENTER><P><A HREF="ch12.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch12.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="ch14.htm" tppabs="http://cheminf.nankai.edu.cn/~eb~/Perl%205%20By%20Example/ch14.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>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月婷婷综合网| 2023国产精品| 亚洲18色成人| 欧美一区欧美二区| 日韩成人精品在线观看| 91精品国产综合久久久久久| 偷拍日韩校园综合在线| 91精品久久久久久久91蜜桃| 精品一区二区免费| 国产欧美精品在线观看| 成人精品视频一区| 亚洲色图在线视频| 欧美日韩精品高清| 九九热在线视频观看这里只有精品| 欧美精品一区二区三区蜜桃视频| 国内精品免费**视频| 国产精品久久久久一区二区三区共| 99热这里都是精品| 五月天一区二区三区| 精品国产乱码久久久久久1区2区| 懂色av一区二区三区蜜臀| 亚洲美女视频一区| 日韩欧美一区在线| 99久久精品国产毛片| 亚洲成人动漫一区| 久久久久久久久久看片| 91蝌蚪porny| 精品一区二区免费视频| 亚洲天堂2016| 日韩免费在线观看| 日本乱人伦aⅴ精品| 秋霞午夜av一区二区三区| 久久久青草青青国产亚洲免观| 91在线精品秘密一区二区| 丝袜美腿高跟呻吟高潮一区| 国产亚洲人成网站| 欧美电影在哪看比较好| 顶级嫩模精品视频在线看| 亚洲不卡一区二区三区| 国产欧美1区2区3区| 欧美日韩不卡一区二区| caoporn国产精品| 强制捆绑调教一区二区| 亚洲天堂av老司机| 久久精品人人做| 4438成人网| 97国产一区二区| 国产福利一区二区三区视频| 亚洲午夜一区二区三区| 国产精品美女久久久久久| 欧美一级欧美一级在线播放| 91年精品国产| 国产不卡视频在线播放| 老司机精品视频在线| 婷婷综合在线观看| 一区二区在线观看av| 亚洲国产精品高清| 精品嫩草影院久久| 91精品国产综合久久久蜜臀粉嫩| 日本乱码高清不卡字幕| 成人激情文学综合网| 韩国v欧美v亚洲v日本v| 美国三级日本三级久久99| 亚洲高清免费观看高清完整版在线观看 | ㊣最新国产の精品bt伙计久久| 日韩精品资源二区在线| 欧美色视频一区| 色94色欧美sute亚洲线路二| 不卡一区二区在线| 成人动漫在线一区| 国产不卡在线视频| 丁香网亚洲国际| 国产69精品久久久久毛片| 国产一区不卡在线| 国产在线视频精品一区| 国产在线精品视频| 国产在线不卡视频| 国产一区二区三区美女| 国产一区二区在线看| 激情成人综合网| 国产精品18久久久| 懂色av中文一区二区三区| 成人永久免费视频| 97se亚洲国产综合自在线观| 色呦呦日韩精品| 欧美综合一区二区| 欧美日韩免费观看一区三区| 欧美三级电影网站| 337p亚洲精品色噜噜| 日韩视频一区二区三区在线播放| 日韩精品一区二区三区在线播放| 久久综合给合久久狠狠狠97色69| 精品福利av导航| 中文字幕欧美区| 亚洲精品免费看| 午夜精品久久久久久| 日本va欧美va欧美va精品| 精品一区免费av| 成人一区二区三区在线观看| 成av人片一区二区| 欧美午夜电影一区| 日韩一区二区电影在线| 久久久久久一二三区| 国产精品久久久久影视| 亚洲午夜精品久久久久久久久| 首页国产欧美久久| 国产做a爰片久久毛片| 成人动漫中文字幕| 555夜色666亚洲国产免| 国产三级精品视频| 亚洲成人1区2区| 国产精品一区二区你懂的| 91丝袜美腿高跟国产极品老师 | 国产不卡视频在线播放| 一本久道中文字幕精品亚洲嫩| 欧美视频一区在线| 久久久影院官网| 亚洲综合丝袜美腿| 韩国中文字幕2020精品| 91在线一区二区三区| 日韩欧美一区二区三区在线| 国产精品全国免费观看高清| 视频一区二区中文字幕| 粉嫩av亚洲一区二区图片| 欧美日韩中字一区| 国产欧美日韩激情| 三级成人在线视频| 99久久婷婷国产精品综合| 日韩欧美在线综合网| 亚洲欧美视频在线观看| 九九精品视频在线看| 欧美三级在线视频| 日本一区二区三区免费乱视频| 午夜av电影一区| 91丨九色丨黑人外教| 精品电影一区二区| 亚洲成av人片一区二区梦乃 | 中文字幕在线免费不卡| 免费久久精品视频| 欧美性色欧美a在线播放| 日本一区二区动态图| 蜜桃视频在线观看一区二区| 色国产综合视频| 国产精品久久久久久久裸模| 久久狠狠亚洲综合| 欧美精品在线一区二区| 亚洲色欲色欲www在线观看| 国产福利一区二区| 欧美xxxxx牲另类人与| 亚洲mv在线观看| 色悠悠久久综合| 国产精品国产a级| 国产激情91久久精品导航| 欧美一区二区三区四区视频| 亚洲一卡二卡三卡四卡无卡久久| k8久久久一区二区三区| 久久久久久9999| 久久国产尿小便嘘嘘| 欧美日韩国产综合视频在线观看| 一区二区三区四区激情| 色哟哟国产精品| 亚洲欧美成aⅴ人在线观看| 成人黄色av电影| 国产精品免费视频网站| 国产69精品一区二区亚洲孕妇 | 国产福利一区在线| 精品国产91乱码一区二区三区| 美女精品自拍一二三四| 日韩欧美不卡在线观看视频| 麻豆精品视频在线观看视频| 在线播放亚洲一区| 日韩va亚洲va欧美va久久| 777a∨成人精品桃花网| 蜜桃视频在线一区| 337p日本欧洲亚洲大胆色噜噜| 极品美女销魂一区二区三区| 欧美大片在线观看一区| 韩国三级在线一区| 国产日韩欧美精品电影三级在线| 国产成人福利片| 国产精品久久久久一区| 97精品久久久久中文字幕| 亚洲人xxxx| 欧美日韩国产高清一区二区三区 | 欧美不卡一二三| 国内成人自拍视频| 中文字幕二三区不卡| 不卡视频免费播放| 亚洲精品日产精品乱码不卡| 欧洲精品中文字幕| 日本视频免费一区| 国产欧美精品一区aⅴ影院| 99久久精品情趣| 一区二区三区免费网站| 69精品人人人人| 国产福利一区在线| 一区二区三区国产精华| 欧美一级免费大片| 国产91精品免费| 亚洲一区视频在线|