Perl::...arators(3pm)
π NAME
ok so this is the Perl::...arators(3pm) page (the title's truncated, iykyk, it's the man-page short form) and it's covering Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators β which literally just means: write 141_234_397.0145 instead of 141234397.0145. that's the whole vibe. β¨
π«Ά AFFILIATION
This Policy is part of the core Perl::Critic distribution. so like, it ships with the gang, no extra install arc needed. π
π₯ DESCRIPTION
okay so listen bestie β long numbers are genuinely hard to read. like, your eyes just kinda glaze over and you're counting digits with your finger like it's 2009. π
but good news: Perl lets you split numbers into groups of digits separated by underscores, which is iconic of it honestly. π
This policy requires number sequences of more than three digits to be separated. no cap, that's the rule.
$long_int = 123456789; #not ok
$long_int = 123_456_789; #ok
$long_float = 12345678.001; #not ok
$long_float = 12_345_678.001; #ok
see how much better that second one looks? main character energy. π
βοΈ CONFIGURATION
The minimum absolute value of numbers that must contain separators can be configured via the "min_value" option. π
The default is 10,000; so that means all numbers >= 10,000 and <= -10,000 must have separators. periodt. for example:
[ValuesAndExpressions::RequireNumberSeparators]
min_value = 100000 # That's one-hundred-thousand!
so yeah, crank that up if you want the small-ish numbers to be left alone. πΈ
π NOTES
ngl, there's some fine print β as it is currently written, this policy only works properly with decimal (base 10) numbers. and it is obviously biased toward Western notation. π
the author says they'll try and address those issues in the future β so like, it's giving "known limitation, fix pending" π¦
forewarned is forearmed bestie, don't come for this policy about your hex literals π
π§ AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
π COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.
β that's the whole page! shoutout to perl v5.42.0, dated 2024-10-23, from the User Contributed Perl Documentation crew β mwah, go forth and underscore your digits πππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms