PPI::Token::Number(3)

๐Ÿ’– PPI::Token::Number ๐Ÿ’–

okay bestie, welcome to PPI::Token::Number(3) โ€” the part of the manual where we talk about the class that handles numbers. yes, the crunchy little digit blobs. this is a PPI thing, so it's all about tokenizing Perl source, not about, like, doing math. math is later. ๐Ÿงฎโœจ


๐ŸŒธ NAME ๐ŸŒธ

PPI::Token::Number โ€” the token class for a number. that's it. that's the whole job description. she shows up, she's a number, she slays. ๐Ÿ’…


โœจ SYNOPSIS โœจ

here's what the various number flavors look like when they show up in your Perl:

  $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 )
heads up bestie ๐Ÿšจ the exponential notation one is currently not working. the manual literally says so. i'm not gonna pretend otherwise, i would never lie to you like that. ๐Ÿ˜ญ

๐Ÿฆ‹ INHERITANCE ๐Ÿฆ‹

the family tree, and yes she's got main character energy at the bottom:

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

so she's a PPI::Token, and a PPI::Token is a PPI::Element. iconic lineage fr. ๐Ÿ‘‘


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

the PPI::Token::Number class is what you use for tokens that represent numbers โ€” in all the various types that Perl supports. all of them. every flavor. she's not picky. ๐ŸŒˆ


๐ŸŽ€ METHODS ๐ŸŽ€

base ๐ŸŒŸ

the base method is provided by all of the ::Number subclasses. it's 10 for decimal, 16 for hexadecimal, 2 for binary, etc. so like, it tells you what number system you're in. no cap, that's the whole vibe.

literal โœจ

return the numeric value of this token. that's the description, that's the whole thing, short and sweet, she ate and left no crumbs. ๐Ÿ“


๐Ÿ˜ญ CAVEATS ๐Ÿ˜ญ

okay so this is the part where we get a lil real. compared to Perl, the number tokenizer is too liberal about allowing underscores anywhere. like, anywhere. she does not care. she will not stop you.

for example, the following is a syntax error in Perl, but is allowed in PPI:

  0_b10
so like โ€” Perl would yell at you for that. PPI is just gonna sit there and let it happen. vibe check failed but she let it slide anyway. ๐Ÿ™ˆ

๐Ÿซถ TO DO ๐Ÿซถ

the list of things that haven't happened yet, bestie, and we're being honest about it:

  • 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. go look, it's right there. ๐Ÿซถ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Adam Kennedy <adamk@cpan.org> โ€” thank you for your service king ๐Ÿซก๐Ÿ’–


copyright 2001 - 2011 Adam Kennedy.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

the full text of the license can be found in the LICENSE file included with this module.


and that's the whole page babes!! ๐ŸŽ€ this was perl v5.42.0, dated 2026-01-17, and it was PPI::Token::Number(3) the entire time. go tokenize some numbers, you're gonna do amazing, mwah ๐Ÿ’‹โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from