Errno#

Native implementation of Errno

Provides system errno constants for Linux. In real Perl, Errno.pm is auto-generated from system headers. We provide the same constants via native Rust implementation using the libc crate.

The module exports constant subs like ENOENT(), EACCES(), etc. that return the errno integer value. It also provides TIEHASH, FETCH, STORE, EXISTS, FIRSTKEY, NEXTKEY methods for the %! tied hash.

Perl equivalent: Errno

Functions#

EPERM, ENOENT, ESRCH, … (errno constants)#

Each errno name is a constant sub returning its integer value. Over 100 Linux errno constants are provided (see ERRNO_CONSTANTS).

use Errno qw(ENOENT EACCES);
if ($! == ENOENT) { ... }

TIEHASH#

Ties the %! hash to the Errno module. Called implicitly by the runtime.

tie %!, 'Errno';

FETCH#

Looks up an errno constant by name through the tied %! hash.

my $val = $!{ENOENT};  # returns 2

EXISTS#

Checks whether a given name is a known errno constant.

if (exists $!{ENOENT}) { ... }

FIRSTKEY#

Returns the first errno constant name. Used by each %! and keys %!.

my $first = (keys %!)[0];  # "EPERM"

NEXTKEY#

Returns the next errno constant name after a given key. Drives hash iteration over %!.

while (my ($k, $v) = each %!) { ... }