Name
oct
Synopsis
oct ostring
Interprets ostring
as an
octal string and returns the equivalent decimal value. (If
ostring
happens to start with 0x
, it is interpreted as a hex string
instead.) The following will handle decimal, octal, and hex in the
standard notation:
$val = oct $val if $val =~ /^0/;
If ostring
is omitted, the
function interprets $_
. To
perform the inverse function on octal numbers, use:
$oct_string = sprintf "%lo", $number;
Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.