Errno#

📦 min

Symbolic names for the errno(3) values your system uses — EINTR, EAGAIN, ENOENT, EACCES, EEXIST, EIO, ENOTDIR, EISDIR, EBUSY, EPIPE, ECONNRESET, ECONNREFUSED, ETIMEDOUT, and every other errno name the host libc defines.

Most scripts reach for Errno to compare $! against a specific error after a failed system call, or to probe %! for the same purpose without touching $! by name.

Synopsis#

use Errno qw(EINTR EAGAIN);

if ($! == EINTR) { retry() }     # function form
if ($!{EAGAIN})  { backoff() }   # hash form via %!

The numeric values come from the libc the pperl binary was built against (Linux glibc or musl), so scripts see exactly the errnos the kernel will actually raise on this host. The :POSIX tag groups the 74 POSIX-standard names for bulk import.

Functions#

Predicate helpers#

tiehash#

Install the tie behind %! so lookups like $!{EINTR} start working.

fetch#

Read $!{NAME}: gives the errno value when the last system error matches that name, 0 when the name is a known errno but does not match, and the empty string when the name is not an errno at all.

exists#

Answer exists $!{NAME}: true when the name is a known errno on this host, false otherwise. The current value of $! is not consulted.

firstkey#

Start iteration over %! — the first key that keys %! or each %! returns.

nextkey#

Continue iteration over %! — the errno name that follows the previous one in keys %! or each %!, or undef at the end.

store#

Refuse any attempt to write, clear, or delete entries in %!. Assigning to $!{ENOENT}, clearing %!, or deleting a key all raise ERRNO hash is read only!.

tie_it#

Internal startup hook that activates the %! tie. Not part of the user-facing API; scripts use %! directly and never call this.