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 โญ
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
- fedora 44: perl-PPI 1.284-2.fc44 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms