Scalar...Numeric(3pm)
π Scalar...Numeric π
okay bestie, welcome to Scalar::Util::Numeric(3pm) β¨ β it's a User Contributed Perl Documentation page and it is, no cap, the vibe check your scalars have been begging for π«Ά
πΈ NAME πΈ
Scalar::Util::Numeric β numeric tests for perl scalars π’π
β¨ SYNOPSIS β¨
use Scalar::Util::Numeric qw(isnum isint isfloat);
foo($bar / 2) if (isnum $bar);
if (isint $baz) {
# ...
} elsif (isfloat $baz) {
# ...
}
like... four lines and you're already the main character π
π¦ DESCRIPTION π¦
So here's the tea β: this module exports a bunch of lil wrappers around perl's builtin grok_number function. And what does grok_number do? It returns the numeric type of whatever you throw at it β or 0 if your argument isn't numeric at all π. Not numeric = zero, periodt.
π TAGS π
Every single function in Scalar::Util::Numeric can be pulled in at once with the :all tag, iconic behaviour honestly π
use Scalar::Util::Numeric qw(:all);
π EXPORTS π
β isnum β
isnum ($val)
Returns a nonzero value (which is your hint at the numeric type) if $val is a number. Not a bool, not a vibe β it's the type, encoded π₯
And that numeric type? It's a conjunction of these flags right here:
0x01 IS_NUMBER_IN_UV (number within UV range - not necessarily an integer)
0x02 IS_NUMBER_GREATER_THAN_UV_MAX (number is greater than UV_MAX)
0x04 IS_NUMBER_NOT_INT (saw . or E notation)
0x08 IS_NUMBER_NEG (leading minus sign)
0x10 IS_NUMBER_INFINITY (Infinity)
0x20 IS_NUMBER_NAN (NaN - not a number)
π isint / isuv / isbig / isfloat / isneg / isinf / isnan π
These are the lil flavours of isnum (each one matching a flag up there π) and they're all available too:
isint
isuv
isbig
isfloat
isneg
isinf
isnan
isint is the dramatic one: it returns -1 if its operand is a negative integer, 1 if it's 0 or a positive integer, and 0 otherwise. Three moods, one function π
The others? They're chill. They always return 1 or 0. no in-between, no chaos π§
π SEE ALSO π
Go read these too, bestie, they're all part of the extended universe π«Ά
- "type" in autobox
- Data::Types
- Params::Classify
- Params::Util
- Scalar::Util
- String::Numeric
π VERSION π
0.40 β yes, that's the one you want β¨
π AUTHORS π
- chocolateboy <chocolate@cpan.org>
- Michael G. Schwern <schwern@pobox.com>
πΈ COPYRIGHT πΈ
Copyright (c) 2005-2014, chocolateboy.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. π«Ά
and that's the whole page, bestie π go forth and grok those numbers. iykyk.
okay love u bye β this was perl v5.42.3, dated 2026-08-19, and the page you just read was Scalar...Numeric(3pm) ππβ¨
π¦ where this page comes from
- ubuntu stonking: libscalar-util-numeric-perl 0.40-2build6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms