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 (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