GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Cmp::StrOrNumeric(3) User Contributed Perl Documentation Data::Cmp::StrOrNumeric(3)

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

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

 use Data::Cmp::StrOrNumeric qw(cmp_data);
 cmp_data(["a", "b", "c"], ["a", "b", "d"]);            # => -1
 cmp_data([0, 1, 10], [0, 1, 9]);                       # => 1

Contrasted with Data::Cmp:

 use Data::Cmp ();
 Data::Cmp::cmp_data(["a", "b", "c"], ["a", "b", "d"]); # => -1
 Data::Cmp::cmp_data([0, 1, 10], [0, 1, 9]);            # => -1

Perform numeric comparison with some tolerance:

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

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

Usage:

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

This module's cmp_data() is just like Data::Cmp's except that when the two non-references being compared look like number (tested using Scalar::Util's looks_like_number(), they are compared with "<=>" instead of "cmp". If none or only one of the non-reference is a number, "cmp" is used like in Data::Cmp.

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

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

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.

Data::Cmp

Data::Cmp::Numeric

perlancar <perlancar@cpan.org>

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.

2021-04-12 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.