PPI::Token::Number(3pm)

PPI::Token::Number3pm

Token class for a number

Usage

  $n = 1234;       # decimal integer
  $n = 0b1110011;  # binary integer
  $n = 01234;      # octal integer
  $n = 0x1234;     # hexadecimal integer
  $n = 12.34e-56;  # exponential notation ( currently not working )

Inheritance

  PPI::Token::Number
  isa PPI::Token
      isa PPI::Element

Overview

The "PPI::Token::Number" class is used for tokens that represent numbers, in the various types that Perl supports.

Methods

base

The "base" method is provided by all of the ::Number subclasses. This is 10 for decimal, 16 for hexadecimal, 2 for binary, etc.

literal

Return the numeric value of this token.

Caveats

Compared to Perl, the number tokenizer is too liberal about allowing underscores anywhere. For example, the following is a syntax error in Perl, but is allowed in PPI:

   0_b10

To do

- Treat v-strings as binary strings or barewords, not as "base-256"
numbers

- Break out decimal integers into their own subclass?

- Implement literal()

Support

See the support section in the main module.

Releases

11 releases since Debian 4.0 (Etch); the text changed 10 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13
  11. Arch

Author

Adam Kennedy <[email protected]>

From perl-ppi 1.291-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.