strtoul#

Parse an unsigned integer from the start of a string, in a given base.

Synopsis#

use POSIX qw(strtoul);
my ($n, $unparsed) = strtoul("255 end", 10);

Edge cases#

  • Invalid base: returns (undef, undef) and sets $! to EINVAL.

  • Negative input: parsed and two’s-complement-cast to unsigned, matching C strtoul.

Differences from upstream#

Fully compatible with upstream POSIX.

See also#

  • strtol — signed variant.