Errno(3pm)
π NAME π
okay so this page is Errno(3pm) β that's the manual name, bestie β from the Perl Programmers Reference Guide, and it's literally all about system errno constants. It's the module that's like "I know your system's error numbers" and honestly? iconic. π β¨
π¦ SYNOPSIS π¦
Use it like this, no cap:
use Errno qw(EINTR EIO :POSIX);
πΈ DESCRIPTION πΈ
Errno defines and conditionally exports all the error constants defined in your system errno.h include file. It has a single export tag, :POSIX, which will export all POSIX defined error numbers.
On Windows, Errno also defines and conditionally exports all the Winsock error constants defined in your system WinError.h include file. These are included in a second export tag, :WINSOCK.
Errno also makes %! magic such that each element of %! has a non-zero value only if $! is set to that value. For example:
my $fh;
unless (open($fh, "<", "/fangorn/spouse")) {
if ($!{ENOENT}) {
warn "Get a wife!\n";
} else {
warn "This path is barred: $!";
}
}
If a specified constant EFOO does not exist on the system, $!{EFOO} returns "". You may use exists $!{EFOO} to check whether the constant is available on the system.
Perl automatically loads Errno the first time you use %!, so you don't need an explicit use.
π CAVEATS π
Importing a particular constant may not be very portable, because the import will fail on platforms that do not have that constant. A more portable way to set $! to a valid value is to use:
if (exists &Errno::EFOO) {
$! = &Errno::EFOO;
}
bestie, this is the "check first" moment: if the platform doesn't have the constant, the import will fail. That's the whole caveat, fr fr. π«Ά
π AUTHOR π
Graham Barr <gbarr@pobox.com> β slay.
π COPYRIGHT π
Copyright (c) 1997-8 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
kisses and slay, this page is from perl v5.42.3 dated 2026-11-03, and the manual page is Errno(3pm). πβ¨π¦
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms