Number::Compare(3pm)

Number::Compare3pm

Numeric comparisons

Usage

 Number::Compare->new(">1Ki")->test(1025); # is 1025 > 1024
 my $c = Number::Compare->new(">1M");
 $c->(1_200_000);                          # slightly terser invocation

Overview

Number::Compare compiles a simple comparison to an anonymous subroutine, which you can call with a value to be tested again.

Now this would be very pointless, if Number::Compare didn't understand magnitudes.

The target value may use magnitudes of kilobytes ("k", "ki"), megabytes ("m", "mi"), or gigabytes ("g", "gi"). Those suffixed with an "i" use the appropriate 2**n version in accordance with the IEC standard: http://physics.nist.gov/cuu/Units/binary.html

Methods

->new( $test )

Returns a new object that compares the specified test.

->test( $value )

A longhanded version of $compare->( $value ). Predates blessed subroutine reference implementation.

->parse_to_perl( $test )

Returns a perl code fragment equivalent to the test.

Releases

12 releases since Debian 3.1 (Sarge); the text changed 7 times.

  1. 3.1
  2. 4.0
  3. 5.0
  4. 6.0
  5. 7–10
  6. 11
  7. 12–13
  8. Arch

Author

Richard Clamp <[email protected]>

From perl-number-compare 0.03-17 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.