- 论坛徽章:
- 1
|
TelNet.pm如何捕捉超时?
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
errmode - define action to be performed on error
$mode = $obj->;errmode;
$prev = $obj->;errmode($mode);
This method gets or sets the action used when errors are encountered using the object. The first calling sequence returns the current error mode. The second calling sequence sets it to $mode and returns the previous mode. Valid values for $mode are "die" (the default), "return", a coderef, or an arrayref.
When mode is "die" and an error is encountered using the object, then an error message is printed to standard error and the program dies.
When mode is "return" then the method generating the error places an error message in the object and returns an undefined value in a scalar context and an empty list in list context. The error message may be obtained using errmsg().
When mode is a coderef, then when an error is encountered coderef is called with the error message as its first argument. Using this mode you may have your own subroutine handle errors. If coderef itself returns then the method generating the error returns undefined or an empty list depending on context.
When mode is an arrayref, the first element of the array must be a coderef. Any elements that follow are the arguments to coderef. When an error is encountered, the coderef is called with its arguments. Using this mode you may have your own subroutine handle errors. If the coderef itself returns then the method generating the error returns undefined or an empty list depending on context.
A warning is printed to STDERR when attempting to set this attribute to something that's not "die", "return", a coderef, or an arrayref whose first element isn't a coderef.
看仔細...你會找到你要的答案的.. |
|