< Perl Programming < Keywords

The code
The oct keyword
oct is a function that interprets EXPRESSION as a string with an octal value. If, however, the expression starts with "0b" or "0x", it interprets its value as binary or hexadecimal, respectively. A leading whitespace is always ignored.
Without the EXPRESSION, $_ is used as the source.
Syntax
oct EXPRESSION
oct
Examples

$a = oct("1773") + 20;
print $a;
prints :
1039
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.