- 论坛徽章:
- 0
|
回复 #5 dugu072 的帖子
绝对是可以改的
perlvar上也说的很清楚了
If used in a numeric context, yields the current value of errno, with all the usual caveats. (This means that you shouldn't depend on the value of $! to be anything in particular unless you've gotten a specific error return indicating a system error.) If used in a string context, yields the corresponding system error string. You can assign to $! to set errno if, for instance, you want "$!" to return the string for error n, or you want to set the exit value for the die() operator. (Mnemonic: What just went bang?)
注意其中的assign
- use strict;
- use warnings;
- foreach ( 1 .. 10 ) {
- $! = $_;
- print "###Error info for $_ is ####\n";
- print $!, "\n";
- print "#" x 30, " \n ";
- }
复制代码
你用上面的代码就可以把errno对应的错误提示都给打印一遍
loser@loserking:~$ ./a.pl
###Error info for 1 is ####
Operation not permitted
##############################
###Error info for 2 is ####
No such file or directory
##############################
###Error info for 3 is ####
No such process
##############################
###Error info for 4 is ####
Interrupted system call
##############################
###Error info for 5 is ####
Input/output error
##############################
###Error info for 6 is ####
No such device or address
##############################
###Error info for 7 is ####
Argument list too long
##############################
###Error info for 8 is ####
Exec format error
##############################
###Error info for 9 is ####
Bad file descriptor
##############################
###Error info for 10 is ####
No child processes
##############################
[ 本帖最后由 churchmice 于 2009-9-19 14:17 编辑 ] |
|