NAME

Data::Cmp::Numeric - Compare two data structures, return -1/0/1 like <=>

VERSION

This document describes version 0.008 of Data::Cmp::Numeric (from Perl distribution Data-Cmp), released on 2021-04-12.

SYNOPSIS

use Data::Cmp::Numeric qw(cmp_data);

cmp_data([0, 1, 10], [0, 1, 9]);                       # =>  1

Contrasted with Data::Cmp:

use Data::Cmp ();
Data::Cmp::cmp_data([0, 1, 10], [0, 1, 9]);            # => -1

Perform numeric comparison with some tolerance:

{
    local $Data::Cmp::Numeric::EPSILON = 1e-3;
    cmp_data(1, 1.1   );     # -1
    cmp_data(1, 1.0001);     #  0
    cmp_data([1], [1.0001]); #  0
}

DESCRIPTION

VARIABLES

$EPSILON

Can be set to perform numeric comparison with some tolerance. See example in Synopsis.

FUNCTIONS

cmp_data

Usage:

cmp_data($d1, $d2) => -1/0/1/2

This module's cmp_data() is just like Data::Cmp's except that two defined non-reference values are compared using Perl's <=> instead of cmp.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Data-Cmp.

SOURCE

Source repository is at https://github.com/perlancar/perl-Data-Cmp.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/perlancar/perl-Data-Cmp/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

Data::Cmp

Data::Cmp::StrOrNumeric

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2019, 2018 by perlancar@cpan.org.

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