Jump to content

Perl Programming/Keywords/oct

From Wikibooks, open books for an open world
Previous: not Keywords Next: open

The oct keyword

[edit | edit source]

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

[edit | edit source]
  oct EXPRESSION
  oct

Examples

[edit | edit source]
The code
  $a = oct("1773") + 20;
  print $a;
prints :
1039
Previous: not Keywords Next: open