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 On Windows, "Errno" also defines and conditionally exports all the
17 Winsock error constants defined in your system WinError.h include file.
18 These are included in a second export tag, ":WINSOCK".
19
20 "Errno" also makes "%!" magic such that each element of "%!" has a non-
21 zero value only if $! is set to that value. For example:
22
23 my $fh;
24 unless (open($fh, "<", "/fangorn/spouse")) {
25 if ($!{ENOENT}) {
26 warn "Get a wife!\n";
27 } else {
28 warn "This path is barred: $!";
29 }
30 }
31
32 If a specified constant "EFOO" does not exist on the system, $!{EFOO}
33 returns "". You may use "exists $!{EFOO}" to check whether the
34 constant is available on the system.
35
36 Perl automatically loads "Errno" the first time you use "%!", so you
37 don't need an explicit "use".
38
40 Importing a particular constant may not be very portable, because the
41 import will fail on platforms that do not have that constant. A more
42 portable way to set $! to a valid value is to use:
43
44 if (exists &Errno::EFOO) {
45 $! = &Errno::EFOO;
46 }
47
49 Graham Barr <gbarr@pobox.com>
50
52 Copyright (c) 1997-8 Graham Barr. All rights reserved. This program is
53 free software; you can redistribute it and/or modify it under the same
54 terms as Perl itself.
55
56
57
58perl v5.26.3 2019-05-11 Errno(3pm)