1Errno(3pm) Perl Programmers Reference Guide Errno(3pm)
2
3
4
6 Errno - System errno constants
7
9 use Errno qw(EINTR EIO :POSIX);
10
12 "Errno" defines and conditionally exports all the error constants
13 defined in your system "errno.h" include file. It has a single export
14 tag, ":POSIX", which will export all POSIX defined error numbers.
15
16 "Errno" also makes "%!" magic such that each element of "%!" has a non-
17 zero value only if $! is set to that value. For example:
18
19 use Errno;
20
21 unless (open(FH, "/fangorn/spouse")) {
22 if ($!{ENOENT}) {
23 warn "Get a wife!\n";
24 } else {
25 warn "This path is barred: $!";
26 }
27 }
28
29 If a specified constant "EFOO" does not exist on the system, $!{EFOO}
30 returns "". You may use "exists $!{EFOO}" to check whether the
31 constant is available on the system.
32
34 Importing a particular constant may not be very portable, because the
35 import will fail on platforms that do not have that constant. A more
36 portable way to set $! to a valid value is to use:
37
38 if (exists &Errno::EFOO) {
39 $! = &Errno::EFOO;
40 }
41
43 Graham Barr <gbarr@pobox.com>
44
46 Copyright (c) 1997-8 Graham Barr. All rights reserved. This program is
47 free software; you can redistribute it and/or modify it under the same
48 terms as Perl itself.
49
50
51
52perl v5.10.1 2017-03-22 Errno(3pm)