oct#

Synopsis#

$val = oct("77");       # 63
$val = oct("0xff");     # 255 (hex)
$val = oct("0b1010");   # 10  (binary)
$val = oct("0o77");     # 63  (explicit octal)

Description#

Interprets a string as an octal number, with automatic prefix dispatch.

Dispatches on prefix: 0x/x for hexadecimal, 0b/b for binary, 0o for explicit octal (Perl 5.34+), otherwise plain octal. Underscores are allowed as digit separators. Leading whitespace is stripped.

See also#

hex