SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

perl-Array-Compare rpm build for : OpenSuSE. For other distributions click perl-Array-Compare.

Name : perl-Array-Compare
Version : 3.0.8 Vendor : obs://build_opensuse_org/devel:languages:perl
Release : lp155.1.2 Date : 2023-05-17 17:57:53
Group : Development/Libraries/Perl Source RPM : perl-Array-Compare-3.0.8-lp155.1.2.src.rpm
Size : 0.02 MB
Packager : https://www_suse_com/
Summary : Perl extension for comparing arrays
Description :
If you have two arrays and you want to know if they are the same or
different, then Array::Compare will be useful to you.

All comparisons are carried out via a comparator object. In the simplest
usage, you can create and use a comparator object like this:

my AATTarr1 = 0 .. 10;
my AATTarr2 = 0 .. 10;

my $comp = Array::Compare->new;

if ($comp->compare(\\AATTarr1, \\AATTarr2)) {
print \"Arrays are the same\
\";
} else {
print \"Arrays are different\
\";
}

Notice that you pass references to the two arrays to the comparison method.

Internally the comparator compares the two arrays by using \'join\' to turn
both arrays into strings and comparing the strings using \'eq\'. In the
joined strings, the elements of the original arrays are separated with the
\'^G\' character. This can cause problems if your array data contains \'^G\'
characters as it is possible that two different arrays can be converted to
the same string.

To avoid this, it is possible to override the default separator character,
either by passing an alternative to the \'new\' function

my $comp = Array::Compare->new(Sep => \'|\');

or by changing the separator for an existing comparator object

$comp->Sep(\'|\');

In general you should choose a separator character that won\'t appear in
your data.

You can also control whether or not whitespace within the elements of the
arrays should be considered significant when making the comparison. The
default is that all whitespace is significant. The alternative is for all
consecutive white space characters to be converted to a single space for
the purposes of the comparison. Again, this can be turned on when creating
a comparator object:

my $comp = Array::Compare->new(WhiteSpace => 0);

or by altering an existing object:

$comp->WhiteSpace(0);

You can also control whether or not the case of the data is significant in
the comparison. The default is that the case of data is taken into account.
This can be changed in the standard ways when creating a new comparator
object:

my $comp = Array::Compare->new(Case => 0);

or by altering an existing object:

$comp->Case(0);

In addition to the simple comparison described above (which returns true if
the arrays are the same and false if they\'re different) there is also a
full comparison which returns a list containing the indexes of elements
which differ between the two arrays. If the arrays are the same it returns
an empty list. In scalar context the full comparison returns the length of
this list (i.e. the number of elements that differ). You can access the
full comparison in two ways. Firstly, there is a \'DefFull\' attribute. If
this is \'true\' then a full comparison is carried out whenever the \'compare\'
method is called.

my $comp = Array::Compare->new(DefFull => 1);
$comp->compare(\\AATTarr1, \\AATTarr2); # Full comparison

$comp->DefFull(0);
$comp->compare(\\AATTarr1, \\AATTarr2); # Simple comparison

$comp->DefFull(1);
$comp->compare(\\AATTarr1, \\AATTarr2); # Full comparison again

Secondly, you can access the full comparison method directly

$comp->full_compare(\\AATTarr1, \\AATTarr2);

For symmetry, there is also a direct method to use to call the simple
comparison.

$comp->simple_compare(\\AATTarr1, \\AATTarr2);

The final complication is the ability to skip elements in the comparison.
If you know that two arrays will always differ in a particular element but
want to compare the arrays _ignoring_ this element, you can do it with
Array::Compare without taking array slices. To do this, a comparator object
has an optional attribute called \'Skip\' which is a reference to a hash. The
keys in this hash are the indexes of the array elements and the values
should be any true value for elements that should be skipped.

For example, if you want to compare two arrays, ignoring the values in
elements two and four, you can do something like this:

my %skip = (2 => 1, 4 => 1);
my AATTa = (0, 1, 2, 3, 4, 5);
my AATTb = (0, 1, X, 3, X, 5);

my $comp = Array::Compare->new(Skip => \\%skip);

$comp->compare(\\AATTa, \\AATTb);

This should return _true_, as we are explicitly ignoring the columns which
differ.

Of course, having created a comparator object with no skip hash, it is
possible to add one later:

$comp->Skip({1 => 1, 2 => 1});

or:

my %skip = (1 => 1, 2 => 2);
$comp->Skip(\\%skip);

To reset the comparator so that no longer skips elements, call NoSkip().

$comp->NoSkip();

You can also check to see if one array is a permutation of another, i.e.
they contain the same elements but in a different order.

if ($comp->perm(\\AATTa, \\AATTb) {
print \"Arrays are perms\
\";
} else {
print \"Nope. Arrays are completely different\
\";
}

In this case the values of \'WhiteSpace\' and \'Case\' are still used, but
\'Skip\' is ignored for, hopefully, obvious reasons.

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/15.5/noarch

Content of RPM  Changelog  Provides Requires

Download
ftp.icm.edu.pl  perl-Array-Compare-3.0.8-lp155.1.2.noarch.rpm
     

Provides :
perl(Array::Compare)
perl-Array-Compare

Requires :
perl(:MODULE_COMPAT_5.26.1)
perl(Moo)
perl(Types::Standard)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1


Content of RPM :
/usr/lib/perl5/vendor_perl/5.26.1/Array
/usr/lib/perl5/vendor_perl/5.26.1/Array/Compare.pm
/usr/share/doc/packages/perl-Array-Compare
/usr/share/doc/packages/perl-Array-Compare/Changes
/usr/share/doc/packages/perl-Array-Compare/README
/usr/share/man/man3/Array::Compare.3pm.gz

 
ICM