Number::Compare(3) User Contributed Perl Documentation Number::Compare(3)

# [NAME](#NAME)

Number::Compare - numeric comparisons

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#DESCRIPTION)

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](#METHODS)

## -&gt;new( $test )

Returns a new object that compares the specified test.

## -&gt;test( $value )

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

## -&gt;parse\_to\_perl( $test )

Returns a perl code fragment equivalent to the test.

# [AUTHOR](#AUTHOR)

Richard Clamp &lt;richardc@unixbeard.net&gt;

# [COPYRIGHT](#COPYRIGHT)

Copyright (C) 2002,2011 Richard Clamp. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

# [SEE ALSO](#SEE_ALSO)

http://physics.nist.gov/cuu/Units/binary.html

2026-10-24 perl v5.44.0

---

Document: Number::Compare(3pm) from perl-number-compare 0.03-r2 (Chainguard OS)
Source: https://cpan.metacpan.org/authors/id/R/RC/RCLAMP/Number-Compare-0.03.tar.gz
