1List::Compare(3) User Contributed Perl Documentation List::Compare(3)
2
3
4
6 List::Compare - Compare elements of two or more lists
7
9 This document refers to version 0.33 of List::Compare. This version
10 was released February 19, 2006.
11
13 The bare essentials:
14
15 @Llist = qw(abel abel baker camera delta edward fargo golfer);
16 @Rlist = qw(baker camera delta delta edward fargo golfer hilton);
17
18 $lc = List::Compare->new(\@Llist, \@Rlist);
19
20 @intersection = $lc->get_intersection;
21 @union = $lc->get_union;
22
23 ... and so forth.
24
26 Regular Case: Compare Two Lists
27
28 * Constructor
29 Create a List::Compare object. Put the two lists into arrays
30 (named or anonymous) and pass references to the arrays to the con‐
31 structor.
32
33 @Llist = qw(abel abel baker camera delta edward fargo golfer);
34 @Rlist = qw(baker camera delta delta edward fargo golfer hilton);
35
36 $lc = List::Compare->new(\@Llist, \@Rlist);
37
38 By default, List::Compare's methods return lists which are sorted
39 using Perl's default "sort" mode: ASCII-betical sorting. Should
40 you not need to have these lists sorted, you may achieve a speed
41 boost by constructing the List::Compare object with the unsorted
42 option:
43
44 $lc = List::Compare->new('-u', \@Llist, \@Rlist);
45
46 or
47
48 $lc = List::Compare->new('--unsorted', \@Llist, \@Rlist);
49
50 * Alternative Constructor
51 If you prefer a more explicit delineation of the types of arguments
52 passed to a function, you may use this 'single hashref' kind of
53 constructor to build a List::Compare object:
54
55 $lc = List::Compare->new( { lists => [\@Llist, \@Rlist] } );
56
57 or
58
59 $lc = List::Compare->new( {
60 lists => [\@Llist, \@Rlist],
61 unsorted => 1,
62 } );
63
64 * Get those items which appear at least once in both lists (their
65 intersection).
66
67 @intersection = $lc->get_intersection;
68
69 * Get those items which appear at least once in either list (their
70 union).
71
72 @union = $lc->get_union;
73
74 * Get those items which appear (at least once) only in the first
75 list.
76
77 @Lonly = $lc->get_unique;
78 @Lonly = $lc->get_Lonly; # alias
79
80 * Get those items which appear (at least once) only in the second
81 list.
82
83 @Ronly = $lc->get_complement;
84 @Ronly = $lc->get_Ronly; # alias
85
86 * Get those items which appear at least once in either the first or
87 the second list, but not both.
88
89 @LorRonly = $lc->get_symmetric_difference;
90 @LorRonly = $lc->get_symdiff; # alias
91 @LorRonly = $lc->get_LorRonly; # alias
92
93 * Make a bag of all those items in both lists. The bag differs from
94 the union of the two lists in that it holds as many copies of indi‐
95 vidual elements as appear in the original lists.
96
97 @bag = $lc->get_bag;
98
99 * An alternative approach to the above methods: If you do not imme‐
100 diately require an array as the return value of the method call,
101 but simply need a reference to an (anonymous) array, use one of the
102 following parallel methods:
103
104 $intersection_ref = $lc->get_intersection_ref;
105 $union_ref = $lc->get_union_ref;
106 $Lonly_ref = $lc->get_unique_ref;
107 $Lonly_ref = $lc->get_Lonly_ref; # alias
108 $Ronly_ref = $lc->get_complement_ref;
109 $Ronly_ref = $lc->get_Ronly_ref; # alias
110 $LorRonly_ref = $lc->get_symmetric_difference_ref;
111 $LorRonly_ref = $lc->get_symdiff_ref; # alias
112 $LorRonly_ref = $lc->get_LorRonly_ref; # alias
113 $bag_ref = $lc->get_bag_ref;
114
115 * Return a true value if the first argument passed to the constructor
116 ('L' for 'left') is a subset of the second argument passed to the
117 constructor ('R' for 'right').
118
119 $LR = $lc->is_LsubsetR;
120
121 Return a true value if R is a subset of L.
122
123 $RL = $lc->is_RsubsetL;
124
125 * Return a true value if the two lists passed to the constructor are
126 equivalent, i.e. if every element in the left-hand list ('L')
127 appears at least once in the right-hand list ('R') and vice versa.
128
129 $eqv = $lc->is_LequivalentR;
130 $eqv = $lc->is_LeqvlntR; # alias
131
132 * Return a true value if the two lists passed to the constructor are
133 disjoint, i.e. if the two lists have zero elements in common (or,
134 what is the same thing, if their intersection is an empty set).
135
136 $disj = $lc->is_LdisjointR;
137
138 * Pretty-print a chart showing whether one list is a subset of the
139 other.
140
141 $lc->print_subset_chart;
142
143 * Pretty-print a chart showing whether the two lists are equivalent
144 (same elements found at least once in both).
145
146 $lc->print_equivalence_chart;
147
148 * Determine in which (if any) of the lists passed to the constructor
149 a given string can be found. In list context, return a list of
150 those indices in the constructor's argument list corresponding to
151 lists holding the string being tested.
152
153 @memb_arr = $lc->is_member_which('abel');
154
155 In the example above, @memb_arr will be:
156
157 ( 0 )
158
159 because 'abel' is found only in @Al which holds position 0 in the
160 list of arguments passed to "new()".
161
162 * In scalar context, the return value is the number of lists passed
163 to the constructor in which a given string is found.
164
165 * As with other List::Compare methods which return a list, you may
166 wish the above method returned a (scalar) reference to an array
167 holding the list:
168
169 $memb_arr_ref = $lc->is_member_which_ref('baker');
170
171 In the example above, $memb_arr_ref will be:
172
173 [ 0, 1 ]
174
175 because 'baker' is found in @Llist and @Rlist, which hold positions
176 0 and 1, respectively, in the list of arguments passed to "new()".
177
178 Note: methods "is_member_which()" and "is_member_which_ref" test
179 only one string at a time and hence take only one argument. To
180 test more than one string at a time see the next method, "are_mem‐
181 bers_which()".
182
183 * Determine in which (if any) of the lists passed to the constructor
184 one or more given strings can be found. The strings to be tested
185 are placed in an array (named or anonymous); a reference to that
186 array is passed to the method.
187
188 $memb_hash_ref =
189 $lc->are_members_which([ qw⎪ abel baker fargo hilton zebra ⎪ ]);
190
191 Note: In versions of List::Compare prior to 0.25 (April 2004), the
192 strings to be tested could be passed as a flat list. This is no
193 longer possible; the argument must now be a reference to an array.
194
195 The return value is a reference to a hash of arrays. The key for
196 each element in this hash is the string being tested. Each ele‐
197 ment's value is a reference to an anonymous array whose elements
198 are those indices in the constructor's argument list corresponding
199 to lists holding the strings being tested. In the examples above,
200 $memb_hash_ref will be:
201
202 {
203 abel => [ 0 ],
204 baker => [ 0, 1 ],
205 fargo => [ 0, 1 ],
206 hilton => [ 1 ],
207 zebra => [ ],
208 };
209
210 Note: "are_members_which()" can take more than one argument;
211 "is_member_which()" and "is_member_which_ref()" each take only one
212 argument. Unlike those two methods, "are_members_which()" returns
213 a hash reference.
214
215 * Determine whether a given string can be found in any of the lists
216 passed as arguments to the constructor. Return 1 if a specified
217 string can be found in any of the lists and 0 if not.
218
219 $found = $lc->is_member_any('abel');
220
221 In the example above, $found will be 1 because 'abel' is found in
222 one or more of the lists passed as arguments to "new()".
223
224 * Determine whether a specified string or strings can be found in any
225 of the lists passed as arguments to the constructor. The strings
226 to be tested are placed in an array (named or anonymous); a refer‐
227 ence to that array is passed to "are_members_any".
228
229 $memb_hash_ref = $lc->are_members_any([ qw⎪ abel baker fargo hilton zebra ⎪ ]);
230
231 Note: In versions of List::Compare prior to 0.25 (April 2004), the
232 strings to be tested could be passed as a flat list. This is no
233 longer possible; the argument must now be a reference to an array.
234
235 The return value is a reference to a hash where an element's key is
236 the string being tested and the element's value is 1 if the string
237 can be found in any of the lists and 0 if not. In the examples
238 above, $memb_hash_ref will be:
239
240 {
241 abel => 1,
242 baker => 1,
243 fargo => 1,
244 hilton => 1,
245 zebra => 0,
246 };
247
248 "zebra"'s value is 0 because "zebra" is not found in either of the
249 lists passed as arguments to "new()".
250
251 * Return current List::Compare version number.
252
253 $vers = $lc->get_version;
254
255 Accelerated Case: When User Only Wants a Single Comparison
256
257 * Constructor
258 If you are certain that you will only want the results of a single
259 comparison, computation may be accelerated by passing '-a' or
260 "'--accelerated" as the first argument to the constructor.
261
262 @Llist = qw(abel abel baker camera delta edward fargo golfer);
263 @Rlist = qw(baker camera delta delta edward fargo golfer hilton);
264
265 $lca = List::Compare->new('-a', \@Llist, \@Rlist);
266
267 or
268
269 $lca = List::Compare->new('--accelerated', \@Llist, \@Rlist);
270
271 As with List::Compare's Regular case, should you not need to have a
272 sorted list returned by an accelerated List::Compare method, you
273 may achieve a speed boost by constructing the accelerated
274 List::Compare object with the unsorted option:
275
276 $lca = List::Compare->new('-u', '-a', \@Llist, \@Rlist);
277
278 or
279
280 $lca = List::Compare->new('--unsorted', '--accelerated', \@Llist, \@Rlist);
281
282 * Alternative Constructor
283 You may use the 'single hashref' constructor format to build a
284 List::Compare object calling for the Accelerated mode:
285
286 $lca = List::Compare->new( {
287 lists => [\@Llist, \@Rlist],
288 accelerated => 1,
289 } );
290
291 or
292
293 $lca = List::Compare->new( {
294 lists => [\@Llist, \@Rlist],
295 accelerated => 1,
296 unsorted => 1,
297 } );
298
299 * Methods
300 All the comparison methods available in the Regular case are avail‐
301 able to you in the Accelerated case as well.
302
303 @intersection = $lca->get_intersection;
304 @union = $lca->get_union;
305 @Lonly = $lca->get_unique;
306 @Ronly = $lca->get_complement;
307 @LorRonly = $lca->get_symmetric_difference;
308 @bag = $lca->get_bag;
309 $intersection_ref = $lca->get_intersection_ref;
310 $union_ref = $lca->get_union_ref;
311 $Lonly_ref = $lca->get_unique_ref;
312 $Ronly_ref = $lca->get_complement_ref;
313 $LorRonly_ref = $lca->get_symmetric_difference_ref;
314 $bag_ref = $lca->get_bag_ref;
315 $LR = $lca->is_LsubsetR;
316 $RL = $lca->is_RsubsetL;
317 $eqv = $lca->is_LequivalentR;
318 $disj = $lca->is_LdisjointR;
319 $lca->print_subset_chart;
320 $lca->print_equivalence_chart;
321 @memb_arr = $lca->is_member_which('abel');
322 $memb_arr_ref = $lca->is_member_which_ref('baker');
323 $memb_hash_ref = $lca->are_members_which(
324 [ qw⎪ abel baker fargo hilton zebra ⎪ ]);
325 $found = $lca->is_member_any('abel');
326 $memb_hash_ref = $lca->are_members_any(
327 [ qw⎪ abel baker fargo hilton zebra ⎪ ]);
328 $vers = $lca->get_version;
329
330 All the aliases for methods available in the Regular case are
331 available to you in the Accelerated case as well.
332
333 Multiple Case: Compare Three or More Lists
334
335 * Constructor
336 Create a List::Compare object. Put each list into an array and
337 pass references to the arrays to the constructor.
338
339 @Al = qw(abel abel baker camera delta edward fargo golfer);
340 @Bob = qw(baker camera delta delta edward fargo golfer hilton);
341 @Carmen = qw(fargo golfer hilton icon icon jerky kappa);
342 @Don = qw(fargo icon jerky);
343 @Ed = qw(fargo icon icon jerky);
344
345 $lcm = List::Compare->new(\@Al, \@Bob, \@Carmen, \@Don, \@Ed);
346
347 As with List::Compare's Regular case, should you not need to have a
348 sorted list returned by a List::Compare method, you may achieve a
349 speed boost by constructing the object with the unsorted option:
350
351 $lcm = List::Compare->new('-u', \@Al, \@Bob, \@Carmen, \@Don, \@Ed);
352
353 or
354
355 $lcm = List::Compare->new('--unsorted', \@Al, \@Bob, \@Carmen, \@Don, \@Ed);
356
357 * Alternative Constructor
358 You may use the 'single hashref' constructor format to build a
359 List::Compare object to process three or more lists at once:
360
361 $lcm = List::Compare->new( {
362 lists => [\@Al, \@Bob, \@Carmen, \@Don, \@Ed],
363 } );
364
365 or
366
367 $lcm = List::Compare->new( {
368 lists => [\@Al, \@Bob, \@Carmen, \@Don, \@Ed],
369 unsorted => 1,
370 } );
371
372 * Multiple Mode Methods Analogous to Regular and Accelerated Mode Meth‐
373 ods
374 Each List::Compare method available in the Regular and Accelerated
375 cases has an analogue in the Multiple case. However, the results
376 produced usually require more careful specification.
377
378 Note: Certain of the following methods available in List::Com‐
379 pare's Multiple mode take optional numerical arguments where those
380 numbers represent the index position of a particular list in the
381 list of arguments passed to the constructor. To specify this index
382 position correctly,
383
384 * start the count at 0 (as is customary with Perl array indices);
385 and
386
387 * do not count any unsorted option ('-u' or '--unsorted') preced‐
388 ing the array references in the constructor's own argument
389 list.
390
391 Example:
392
393 $lcmex = List::Compare->new('--unsorted', \@alpha, \@beta, \@gamma);
394
395 For the purpose of supplying a numerical argument to a method which
396 optionally takes such an argument, '--unsorted' is skipped, @alpha
397 is 0, @beta is 1, and so forth.
398
399 * Get those items found in each of the lists passed to the con‐
400 structor (their intersection):
401
402 @intersection = $lcm->get_intersection;
403
404 * Get those items found in any of the lists passed to the con‐
405 structor (their union):
406
407 @union = $lcm->get_union;
408
409 * To get those items which appear only in one particular list,
410 provide "get_unique()" with that list's index position in the
411 list of arguments passed to the constructor (not counting any
412 '-u' or '--unsorted' option).
413
414 Example: @Carmen has index position 2 in the constructor's @_.
415 To get elements unique to @Carmen:
416
417 @Lonly = $lcm->get_unique(2);
418
419 If no index position is passed to "get_unique()" it will
420 default to 0 and report items unique to the first list passed
421 to the constructor.
422
423 * To get those items which appear in any list other than one par‐
424 ticular list, provide "get_complement()" with that list's index
425 position in the list of arguments passed to the constructor
426 (not counting any '-u' or '--unsorted' option).
427
428 Example: @Don has index position 3 in the constructor's @_.
429 To get elements not found in @Don:
430
431 @Ronly = $lcm->get_complement(3);
432
433 If no index position is passed to "get_complement()" it will
434 default to 0 and report items found in any list other than the
435 first list passed to the constructor.
436
437 * Get those items each of which appears in only one of the lists
438 passed to the constructor (their symmetric_difference);
439
440 @LorRonly = $lcm->get_symmetric_difference;
441
442 * Make a bag of all items found in any list. The bag differs
443 from the lists' union in that it holds as many copies of indi‐
444 vidual elements as appear in the original lists.
445
446 @bag = $lcm->get_bag;
447
448 * An alternative approach to the above methods: If you do not
449 immediately require an array as the return value of the method
450 call, but simply need a reference to an array, use one of the
451 following parallel methods:
452
453 $intersection_ref = $lcm->get_intersection_ref;
454 $union_ref = $lcm->get_union_ref;
455 $Lonly_ref = $lcm->get_unique_ref(2);
456 $Ronly_ref = $lcm->get_complement_ref(3);
457 $LorRonly_ref = $lcm->get_symmetric_difference_ref;
458 $bag_ref = $lcm->get_bag_ref;
459
460 * To determine whether one particular list is a subset of another
461 list passed to the constructor, provide "is_LsubsetR()" with
462 the index position of the presumed subset (ignoring any
463 unsorted option), followed by the index position of the pre‐
464 sumed superset.
465
466 Example: To determine whether @Ed is a subset of @Carmen,
467 call:
468
469 $LR = $lcm->is_LsubsetR(4,2);
470
471 A true value (1) is returned if the left-hand list is a subset
472 of the right-hand list; a false value (0) is returned other‐
473 wise.
474
475 If no arguments are passed, "is_LsubsetR()" defaults to "(0,1)"
476 and compares the first two lists passed to the constructor.
477
478 * To determine whether any two particular lists are equivalent to
479 each other, provide "is_LequivalentR" with their index posi‐
480 tions in the list of arguments passed to the constructor
481 (ignoring any unsorted option).
482
483 Example: To determine whether @Don and @Ed are equivalent,
484 call:
485
486 $eqv = $lcm->is_LequivalentR(3,4);
487
488 A true value (1) is returned if the lists are equivalent; a
489 false value (0) otherwise.
490
491 If no arguments are passed, "is_LequivalentR" defaults to
492 "(0,1)" and compares the first two lists passed to the con‐
493 structor.
494
495 * To determine whether any two particular lists are disjoint from
496 each other (i.e., have no members in common), provide "is_Ldis‐
497 jointR" with their index positions in the list of arguments
498 passed to the constructor (ignoring any unsorted option).
499
500 Example: To determine whether @Don and @Ed are disjoint, call:
501
502 $disj = $lcm->is_LdisjointR(3,4);
503
504 A true value (1) is returned if the lists are equivalent; a
505 false value (0) otherwise.
506
507 If no arguments are passed, "is_LdisjointR" defaults to "(0,1)"
508 and compares the first two lists passed to the constructor.
509
510 * Pretty-print a chart showing the subset relationships among the
511 various source lists:
512
513 $lcm->print_subset_chart;
514
515 * Pretty-print a chart showing the equivalence relationships
516 among the various source lists:
517
518 $lcm->print_equivalence_chart;
519
520 * Determine in which (if any) of the lists passed to the con‐
521 structor a given string can be found. In list context, return
522 a list of those indices in the constructor's argument list
523 (ignoring any unsorted option) corresponding to i lists holding
524 the string being tested.
525
526 @memb_arr = $lcm->is_member_which('abel');
527
528 In the example above, @memb_arr will be:
529
530 ( 0 )
531
532 because 'abel' is found only in @Al which holds position 0 in
533 the list of arguments passed to "new()".
534
535 * As with other List::Compare methods which return a list, you
536 may wish the above method returned a (scalar) reference to an
537 array holding the list:
538
539 $memb_arr_ref = $lcm->is_member_which_ref('jerky');
540
541 In the example above, $memb_arr_ref will be:
542
543 [ 3, 4 ]
544
545 because 'jerky' is found in @Don and @Ed, which hold positions
546 3 and 4, respectively, in the list of arguments passed to
547 "new()".
548
549 Note: methods "is_member_which()" and "is_member_which_ref"
550 test only one string at a time and hence take only one argu‐
551 ment. To test more than one string at a time see the next
552 method, "are_members_which()".
553
554 * Determine in "which" (if any) of the lists passed to the con‐
555 structor one or more given strings can be found. The strings
556 to be tested are placed in an anonymous array, a reference to
557 which is passed to the method.
558
559 $memb_hash_ref =
560 $lcm->are_members_which([ qw⎪ abel baker fargo hilton zebra ⎪ ]);
561
562 Note: In versions of List::Compare prior to 0.25 (April 2004),
563 the strings to be tested could be passed as a flat list. This
564 is no longer possible; the argument must now be a reference to
565 an anonymous array.
566
567 The return value is a reference to a hash of arrays. The key
568 for each element in this hash is the string being tested. Each
569 element's value is a reference to an anonymous array whose ele‐
570 ments are those indices in the constructor's argument list cor‐
571 responding to lists holding the strings being tested.
572
573 In the two examples above, $memb_hash_ref will be:
574
575 {
576 abel => [ 0 ],
577 baker => [ 0, 1 ],
578 fargo => [ 0, 1, 2, 3, 4 ],
579 hilton => [ 1, 2 ],
580 zebra => [ ],
581 };
582
583 Note: "are_members_which()" can take more than one argument;
584 "is_member_which()" and "is_member_which_ref()" each take only
585 one argument. "are_members_which()" returns a hash reference;
586 the other methods return either a list or a reference to an
587 array holding that list, depending on context.
588
589 * Determine whether a given string can be found in any of the
590 lists passed as arguments to the constructor.
591
592 $found = $lcm->is_member_any('abel');
593
594 Return 1 if a specified string can be found in any of the lists
595 and 0 if not.
596
597 In the example above, $found will be 1 because 'abel' is found
598 in one or more of the lists passed as arguments to "new()".
599
600 * Determine whether a specified string or strings can be found in
601 any of the lists passed as arguments to the constructor. The
602 strings to be tested are placed in an array (anonymous or
603 named), a reference to which is passed to the method.
604
605 $memb_hash_ref = $lcm->are_members_any([ qw⎪ abel baker fargo hilton zebra ⎪ ]);
606
607 Note: In versions of List::Compare prior to 0.25 (April 2004),
608 the strings to be tested could be passed as a flat list. This
609 is no longer possible; the argument must now be a reference to
610 an anonymous array.
611
612 The return value is a reference to a hash where an element's
613 key is the string being tested and the element's value is 1 if
614 the string can be found in "any" of the lists and 0 if not. In
615 the two examples above, $memb_hash_ref will be:
616
617 {
618 abel => 1,
619 baker => 1,
620 fargo => 1,
621 hilton => 1,
622 zebra => 0,
623 };
624
625 "zebra"'s value will be 0 because "zebra" is not found in any
626 of the lists passed as arguments to "new()".
627
628 * Return current List::Compare version number:
629
630 $vers = $lcm->get_version;
631
632 * Multiple Mode Methods Not Analogous to Regular and Accelerated Mode
633 Methods
634 * Get those items found in any of the lists passed to the con‐
635 structor which do not appear in all of the lists (i.e., all
636 items except those found in the intersection of the lists):
637
638 @nonintersection = $lcm->get_nonintersection;
639
640 * Get those items which appear in more than one of the lists
641 passed to the constructor (i.e., all items except those found
642 in their symmetric difference);
643
644 @shared = $lcm->get_shared;
645
646 * If you only need a reference to an array as a return value
647 rather than a full array, use the following alternative meth‐
648 ods:
649
650 $nonintersection_ref = $lcm->get_nonintersection_ref;
651 $shared_ref = $lcm->get_shared_ref;
652
653 * Get a reference to an array of array references where each of
654 the interior arrays holds the list of those items unique to the
655 list passed to the constructor with the same index position.
656
657 $unique_all_ref = $lcm->get_unique_all();
658
659 In the example above, $unique_all_ref will hold:
660
661 [
662 [ qw⎪ abel ⎪ ],
663 [ ],
664 [ qw⎪ jerky ⎪ ],
665 [ ],
666 [ ],
667 ]
668
669 * Get a reference to an array of array references where each of
670 the interior arrays holds the list of those items in the com‐
671 plement to the list passed to the constructor with the same
672 index position.
673
674 $complement_all_ref = $lcm->get_complement_all();
675
676 In the example above, $complement_all_ref will hold:
677
678 [
679 [ qw⎪ hilton icon jerky ⎪ ],
680 [ qw⎪ abel icon jerky ⎪ ],
681 [ qw⎪ abel baker camera delta edward ⎪ ],
682 [ qw⎪ abel baker camera delta edward jerky ⎪ ],
683 [ qw⎪ abel baker camera delta edward jerky ⎪ ],
684 ]
685
686 Multiple Accelerated Case: Compare Three or More Lists but Request
687 Only a Single Comparison among the Lists
688
689 * Constructor
690 If you are certain that you will only want the results of a single
691 comparison among three or more lists, computation may be acceler‐
692 ated by passing '-a' or "'--accelerated" as the first argument to
693 the constructor.
694
695 @Al = qw(abel abel baker camera delta edward fargo golfer);
696 @Bob = qw(baker camera delta delta edward fargo golfer hilton);
697 @Carmen = qw(fargo golfer hilton icon icon jerky kappa);
698 @Don = qw(fargo icon jerky);
699 @Ed = qw(fargo icon icon jerky);
700
701 $lcma = List::Compare->new('-a',
702 \@Al, \@Bob, \@Carmen, \@Don, \@Ed);
703
704 As with List::Compare's other cases, should you not need to have a
705 sorted list returned by a List::Compare method, you may achieve a
706 speed boost by constructing the object with the unsorted option:
707
708 $lcma = List::Compare->new('-u', '-a',
709 \@Al, \@Bob, \@Carmen, \@Don, \@Ed);
710
711 or
712
713 $lcma = List::Compare->new('--unsorted', '--accelerated',
714 \@Al, \@Bob, \@Carmen, \@Don, \@Ed);
715
716 As was the case with List::Compare's Multiple mode, do not count
717 the unsorted option ('-u' or '--unsorted') or the accelerated
718 option ('-a' or '--accelerated') when determining the index posi‐
719 tion of a particular list in the list of array references passed to
720 the constructor.
721
722 Example:
723
724 $lcmaex = List::Compare->new('--unsorted', '--accelerated',
725 \@alpha, \@beta, \@gamma);
726
727 * Alternative Constructor
728 The 'single hashref' format may be used to construct a List::Com‐
729 pare object which calls for accelerated processing of three or more
730 lists at once:
731
732 $lcmaex = List::Compare->new( {
733 accelerated => 1,
734 lists => [\@alpha, \@beta, \@gamma],
735 } );
736
737 or
738
739 $lcmaex = List::Compare->new( {
740 unsorted => 1,
741 accelerated => 1,
742 lists => [\@alpha, \@beta, \@gamma],
743 } );
744
745 * Methods
746 For the purpose of supplying a numerical argument to a method which
747 optionally takes such an argument, '--unsorted' and "'--acceler‐
748 ated" are skipped, @alpha is 0, @beta is 1, and so forth. To get a
749 list of those items unique to @gamma, you would call:
750
751 @gamma_only = $lcmaex->get_unique(2);
752
753 Passing Seen-hashes to the Constructor Instead of Arrays
754
755 * When Seen-Hashes Are Already Available to You
756 Suppose that in a particular Perl program, you had to do extensive
757 munging of data from an external source and that, once you had cor‐
758 rectly parsed a line of data, it was easier to assign that datum to
759 a hash than to an array. More specifically, suppose that you used
760 each datum as the key to an element of a lookup table in the form
761 of a seen-hash:
762
763 my %Llist = (
764 abel => 2,
765 baker => 1,
766 camera => 1,
767 delta => 1,
768 edward => 1,
769 fargo => 1,
770 golfer => 1,
771 );
772
773 my %Rlist = (
774 baker => 1,
775 camera => 1,
776 delta => 2,
777 edward => 1,
778 fargo => 1,
779 golfer => 1,
780 hilton => 1,
781 );
782
783 In other words, suppose it was more convenient to compute a lookup
784 table implying a list than to compute that list explicitly.
785
786 Since in almost all cases List::Compare takes the elements in the
787 arrays passed to its constructor and internally assigns them to
788 elements in a seen-hash, why shouldn't you be able to pass (refer‐
789 ences to) seen-hashes directly to the constructor and avoid unnec‐
790 essary array assignments before the constructor is called?
791
792 * Constructor
793 You can now do so:
794
795 $lcsh = List::Compare->new(\%Llist, \%Rlist);
796
797 * Methods
798 All of List::Compare's output methods are supported without further
799 modification when references to seen-hashes are passed to the con‐
800 structor.
801
802 @intersection = $lcsh->get_intersection;
803 @union = $lcsh->get_union;
804 @Lonly = $lcsh->get_unique;
805 @Ronly = $lcsh->get_complement;
806 @LorRonly = $lcsh->get_symmetric_difference;
807 @bag = $lcsh->get_bag;
808 $intersection_ref = $lcsh->get_intersection_ref;
809 $union_ref = $lcsh->get_union_ref;
810 $Lonly_ref = $lcsh->get_unique_ref;
811 $Ronly_ref = $lcsh->get_complement_ref;
812 $LorRonly_ref = $lcsh->get_symmetric_difference_ref;
813 $bag_ref = $lcsh->get_bag_ref;
814 $LR = $lcsh->is_LsubsetR;
815 $RL = $lcsh->is_RsubsetL;
816 $eqv = $lcsh->is_LequivalentR;
817 $disj = $lcsh->is_LdisjointR;
818 $lcsh->print_subset_chart;
819 $lcsh->print_equivalence_chart;
820 @memb_arr = $lsch->is_member_which('abel');
821 $memb_arr_ref = $lsch->is_member_which_ref('baker');
822 $memb_hash_ref = $lsch->are_members_which(
823 [ qw⎪ abel baker fargo hilton zebra ⎪ ]);
824 $found = $lsch->is_member_any('abel');
825 $memb_hash_ref = $lsch->are_members_any(
826 [ qw⎪ abel baker fargo hilton zebra ⎪ ]);
827 $vers = $lcsh->get_version;
828 $unique_all_ref = $lcsh->get_unique_all();
829 $complement_all_ref = $lcsh->get_complement_all();
830
831 * Accelerated Mode and Seen-Hashes
832 To accelerate processing when you want only a single comparison
833 among two or more lists, you can pass '-a' or "'--accelerated" to
834 the constructor before passing references to seen-hashes.
835
836 $lcsha = List::Compare->new('-a', \%Llist, \%Rlist);
837
838 To compare three or more lists simultaneously, pass three or more
839 references to seen-hashes. Thus,
840
841 $lcshm = List::Compare->new(\%Alpha, \%Beta, \%Gamma);
842
843 will generate meaningful comparisons of three or more lists simul‐
844 taneously.
845
846 * Unsorted Results and Seen-Hashes
847 If you do not need sorted lists returned, pass '-u' or "--unsorted"
848 to the constructor before passing references to seen-hashes.
849
850 $lcshu = List::Compare->new('-u', \%Llist, \%Rlist);
851 $lcshau = List::Compare->new('-u', '-a', \%Llist, \%Rlist);
852 $lcshmu = List::Compare->new('--unsorted', \%Alpha, \%Beta, \%Gamma);
853
854 As was true when we were using List::Compare's Multiple and Multi‐
855 ple Accelerated modes, do not count any unsorted or accelerated
856 option when determining the array index of a particular seen-hash
857 reference passed to the constructor.
858
859 * Alternative Constructor
860 The 'single hashref' form of constructor is also available to build
861 List::Compare objects where seen-hashes are used as arguments:
862
863 $lcshu = List::Compare->new( {
864 unsorted => 1,
865 lists => [\%Llist, \%Rlist],
866 } );
867
868 $lcshau = List::Compare->new( {
869 unsorted => 1,
870 accelerated => 1,
871 lists => [\%Llist, \%Rlist],
872 } );
873
874 $lcshmu = List::Compare->new( {
875 unsorted => 1,
876 lists => [\%Alpha, \%Beta, \%Gamma],
877 } );
878
880 General Comments
881
882 List::Compare is an object-oriented implementation of very common Perl
883 code (see "History, References and Development" below) used to deter‐
884 mine interesting relationships between two or more lists at a time. A
885 List::Compare object is created and automatically computes the values
886 needed to supply List::Compare methods with appropriate results. In
887 the current implementation List::Compare methods will return new lists
888 containing the items found in any designated list alone (unique), any
889 list other than a designated list (complement), the intersection and
890 union of all lists and so forth. List::Compare also has (a) methods to
891 return Boolean values indicating whether one list is a subset of
892 another and whether any two lists are equivalent to each other (b)
893 methods to pretty-print very simple charts displaying the subset and
894 equivalence relationships among lists.
895
896 Except for List::Compare's "get_bag()" method, multiple instances of an
897 element in a given list count only once with respect to computing the
898 intersection, union, etc. of the two lists. In particular, List::Com‐
899 pare considers two lists as equivalent if each element of the first
900 list can be found in the second list and vice versa. 'Equivalence' in
901 this usage takes no note of the frequency with which elements occur in
902 either list or their order within the lists. List::Compare asks the
903 question: Did I see this item in this list at all? Only when you use
904 "List::Compare::get_bag()" to compute a bag holding the two lists do
905 you ask the question: How many times did this item occur in this list?
906
907 List::Compare Modes
908
909 In its current implementation List::Compare has four modes of opera‐
910 tion.
911
912 · Regular Mode
913
914 List::Compare's Regular mode is based on List::Compare v0.11 -- the
915 first version of List::Compare released to CPAN (June 2002). It
916 compares only two lists at a time. Internally, its initializer
917 does all computations needed to report any desired comparison and
918 its constructor stores the results of these computations. Its pub‐
919 lic methods merely report these results.
920
921 This approach has the advantage that if you need to examine more
922 than one form of comparison between two lists (e.g., the union,
923 intersection and symmetric difference of two lists), the compar‐
924 isons are pre-calculated. This approach is efficient because cer‐
925 tain types of comparison presuppose that other types have already
926 been calculated. For example, to calculate the symmetric differ‐
927 ence of two lists, one must first determine the items unique to
928 each of the two lists.
929
930 · Accelerated Mode
931
932 The current implementation of List::Compare offers you the option
933 of getting even faster results provided that you only need the
934 result from a single form of comparison between two lists. (e.g.,
935 only the union -- nothing else). In the Accelerated mode,
936 List::Compare's initializer does no computation and its constructor
937 stores only references to the two source lists. All computation
938 needed to report results is deferred to the method calls.
939
940 The user selects this approach by passing the option flag '-a' to
941 the constructor before passing references to the two source lists.
942 List::Compare notes the option flag and silently switches into
943 Accelerated mode. From the perspective of the user, there is no
944 further difference in the code or in the results.
945
946 Benchmarking suggests that List::Compare's Accelerated mode (a) is
947 faster than its Regular mode when only one comparison is requested;
948 (b) is about as fast as Regular mode when two comparisons are
949 requested; and (c) becomes considerably slower than Regular mode as
950 each additional comparison above two is requested.
951
952 · Multiple Mode
953
954 List::Compare now offers the possibility of comparing three or more
955 lists at a time. Simply store the extra lists in arrays and pass
956 references to those arrays to the constructor. List::Compare
957 detects that more than two lists have been passed to the construc‐
958 tor and silently switches into Multiple mode.
959
960 As described in the Synopsis above, comparing more than two lists
961 at a time offers you a wider, more complex palette of comparison
962 methods. Individual items may appear in just one source list, in
963 all the source lists, or in some number of lists between one and
964 all. The meaning of 'union', 'intersection' and 'symmetric differ‐
965 ence' is conceptually unchanged when you move to multiple lists
966 because these are properties of all the lists considered together.
967 In contrast, the meaning of 'unique', 'complement', 'subset' and
968 'equivalent' changes because these are properties of one list com‐
969 pared with another or with all the other lists combined.
970
971 List::Compare takes this complexity into account by allowing you to
972 pass arguments to the public methods requesting results with
973 respect to a specific list (for "get_unique()" and "get_comple‐
974 ment()") or a specific pair of lists (for "is_LsubsetR()" and
975 "is_LequivalentR()").
976
977 List::Compare further takes this complexity into account by offer‐
978 ing the new methods "get_shared()" and "get_nonintersection()"
979 described in the Synopsis above.
980
981 · Multiple Accelerated Mode
982
983 Beginning with version 0.25, introduced in April 2004, List::Com‐
984 pare offers the possibility of accelerated computation of a single
985 comparison among three or more lists at a time. Simply store the
986 extra lists in arrays and pass references to those arrays to the
987 constructor preceded by the '-a' argument as was done with the sim‐
988 ple (two lists only) accelerated mode. List::Compare detects that
989 more than two lists have been passed to the constructor and
990 silently switches into Multiple Accelerated mode.
991
992 · Unsorted Option
993
994 When List::Compare is used to return lists representing various
995 comparisons of two or more lists (e.g., the lists' union or inter‐
996 section), the lists returned are, by default, sorted using Perl's
997 default "sort" mode: ASCII-betical sorting. Sorting produces
998 results which are more easily human-readable but may entail a per‐
999 formance cost.
1000
1001 Should you not need sorted results, you can avoid the potential
1002 performance cost by calling List::Compare's constructor using the
1003 unsorted option. This is done by calling '-u' or '--unsorted' as
1004 the first argument passed to the constructor, i.e., as an argument
1005 called before any references to lists are passed to the construc‐
1006 tor.
1007
1008 Note that if are calling List::Compare in the Accelerated or Multi‐
1009 ple Accelerated mode and wish to have the lists returned in
1010 unsorted order, you first pass the argument for the unsorted option
1011 ('-u' or '--unsorted') and then pass the argument for the Acceler‐
1012 ated mode ('-a' or '--accelerated').
1013
1014 Miscellaneous Methods
1015
1016 It would not really be appropriate to call "get_shared()" and "get_non‐
1017 intersection()" in Regular or Accelerated mode since they are conceptu‐
1018 ally based on the notion of comparing more than two lists at a time.
1019 However, there is always the possibility that a user may be comparing
1020 only two lists (accelerated or not) and may accidentally call one of
1021 those two methods. To prevent fatal run-time errors and to caution you
1022 to use a more appropriate method, these two methods are defined for
1023 Regular and Accelerated modes so as to return suitable results but also
1024 generate a carp message that advise you to re-code.
1025
1026 Similarly, the method "is_RsubsetL()" is appropriate for the Regular
1027 and Accelerated modes but is not really appropriate for Multiple mode.
1028 As a defensive maneuver, it has been defined for Multiple mode so as to
1029 return suitable results but also to generate a carp message that
1030 advises you to re-code.
1031
1032 In List::Compare v0.11 and earlier, the author provided aliases for
1033 various methods based on the supposition that the source lists would be
1034 referred to as 'A' and 'B'. Now that you can compare more than two
1035 lists at a time, the author feels that it would be more appropriate to
1036 refer to the elements of two-argument lists as the left-hand and right-
1037 hand elements. Hence, we are discouraging the use of methods such as
1038 "get_Aonly()", "get_Bonly()" and "get_AorBonly()" as aliases for
1039 "get_unique()", "get_complement()" and "get_symmetric_difference()".
1040 However, to guarantee backwards compatibility for the vast audience of
1041 Perl programmers using earlier versions of List::Compare (all 10e1 of
1042 you) these and similar methods for subset relationships are still
1043 defined.
1044
1045 List::Compare::SeenHash Discontinued Beginning with Version 0.26
1046
1047 Prior to v0.26, introduced April 11, 2004, if a user wished to pass
1048 references to seen-hashes to List::Compare's constructor rather than
1049 references to arrays, he or she had to call a different, parallel mod‐
1050 ule: List::Compare::SeenHash. The code for that looked like this:
1051
1052 use List::Compare::SeenHash;
1053
1054 my %Llist = (
1055 abel => 2,
1056 baker => 1,
1057 camera => 1,
1058 delta => 1,
1059 edward => 1,
1060 fargo => 1,
1061 golfer => 1,
1062 );
1063
1064 my %Rlist = (
1065 baker => 1,
1066 camera => 1,
1067 delta => 2,
1068 edward => 1,
1069 fargo => 1,
1070 golfer => 1,
1071 hilton => 1,
1072 );
1073
1074 my $lcsh = List::Compare::SeenHash->new(\%Llist, \%Rlist);
1075
1076 List::Compare::SeenHash is deprecated beginning with version 0.26. All
1077 its functionality (and more) has been implemented in List::Compare
1078 itself, since a user can now pass either a series of array references
1079 or a series of seen-hash references to List::Compare's constructor.
1080
1081 To simplify future maintenance of List::Compare, List::Compare::Seen‐
1082 Hash.pm will no longer be distributed with List::Compare, nor will the
1083 files in the test suite which tested List::Compare::SeenHash upon
1084 installation be distributed.
1085
1086 Should you still need List::Compare::SeenHash, use version 0.25 from
1087 CPAN, or simply edit your Perl programs which used List::Compare::Seen‐
1088 Hash. Those scripts may be edited quickly with, for example, this
1089 editing command in Unix text editor vi:
1090
1091 :1,$s/List::Compare::SeenHash/List::Compare/gc
1092
1093 A Non-Object-Oriented Interface: List::Compare::Functional
1094
1095 Version 0.21 of List::Compare introduced List::Compare::Functional, a
1096 functional (i.e., non-object-oriented) interface to list comparison
1097 functions. List::Compare::Functional supports the same functions cur‐
1098 rently supported by List::Compare. It works similar to List::Compare's
1099 Accelerated and Multiple Accelerated modes (described above), bit it
1100 does not require use of the '-a' flag in the function call. List::Com‐
1101 pare::Functional will return unsorted comparisons of two lists by pass‐
1102 ing '-u' or '--unsorted' as the first argument to the function. Please
1103 see the documentation for List::Compare::Functional to learn how to
1104 import its functions into your main package.
1105
1107 The program was created with Perl 5.6. The use of h2xs to prepare the
1108 module's template installed "require 5.005_62;" at the top of the mod‐
1109 ule. This has been commented out in the actual module as the code
1110 appears to be compatible with earlier versions of Perl; how earlier the
1111 author cannot say. In particular, the author would like the module to
1112 be installable on older versions of MacPerl. As is, the author has
1113 successfully installed the module on Linux, Windows 9x and Windows
1114 2000. See <http://testers.cpan.org/show/List-Compare.html> for a list
1115 of other systems on which this version of List::Compare has been tested
1116 and installed.
1117
1119 The Code Itself
1120
1121 List::Compare is based on code presented by Tom Christiansen & Nathan
1122 Torkington in Perl Cookbook <http://www.oreilly.com/catalog/cookbook/>
1123 (a.k.a. the 'Ram' book), O'Reilly & Associates, 1998, Recipes 4.7 and
1124 4.8. Similar code is presented in the Camel book: Programming Perl,
1125 by Larry Wall, Tom Christiansen, Jon Orwant.
1126 <http://www.oreilly.com/catalog/pperl3/>, 3rd ed, O'Reilly & Asso‐
1127 ciates, 2000. The list comparison code is so basic and Perlish that I
1128 suspect it may have been written by Larry himself at the dawn of Perl
1129 time. The "get_bag()" method was inspired by Jarkko Hietaniemi's
1130 Set::Bag module and Daniel Berger's Set::Array module, both available
1131 on CPAN.
1132
1133 List::Compare's original objective was simply to put this code in a
1134 modular, object-oriented framework. That framework, not surprisingly,
1135 is taken mostly from Damian Conway's Object Oriented Perl
1136 <http://www.manning.com/Conway/index.html>, Manning Publications, 2000.
1137
1138 With the addition of the Accelerated, Multiple and Multiple Accelerated
1139 modes, List::Compare expands considerably in both size and capabili‐
1140 ties. Nonetheless, Tom and Nat's Cookbook code still lies at its
1141 core: the use of hashes as look-up tables to record elements seen in
1142 lists. Please note: List::Compare is not concerned with any concept
1143 of 'equality' among lists which hinges upon the frequency with which,
1144 or the order in which, elements appear in the lists to be compared. If
1145 this does not meet your needs, you should look elsewhere or write your
1146 own module.
1147
1148 The Inspiration
1149
1150 I realized the usefulness of putting the list comparison code into a
1151 module while preparing an introductory level Perl course given at the
1152 New School University's Computer Instruction Center in April-May 2002.
1153 I was comparing lists left and right. When I found myself writing very
1154 similar functions in different scripts, I knew a module was lurking
1155 somewhere. I learned the truth of the mantra ''Repeated Code is a Mis‐
1156 take'' from a 2001 talk by Mark-Jason Dominus <http://perl.plover.com/>
1157 to the New York Perlmongers <http://ny.pm.org/>. See
1158 <http://www.perl.com/pub/a/2000/11/repair3.html>.
1159
1160 The first public presentation of this module took place at Perl Seminar
1161 New York <http://groups.yahoo.com/group/perlsemny> on May 21, 2002.
1162 Comments and suggestions were provided there and since by Glenn Maciag,
1163 Gary Benson, Josh Rabinowitz, Terrence Brannon and Dave Cross.
1164
1165 The placement in the installation tree of Test::ListCompareSpecial came
1166 as a result of a question answered by Michael Graham in his talk
1167 ''Test::More to Test::Extreme'' given at Yet Another Perl Confer‐
1168 ence::Canada in Ottawa, Ontario, on May 16, 2003.
1169
1170 In May-June 2003, Glenn Maciag made valuable suggestions which led to
1171 changes in method names and documentation in v0.20.
1172
1173 Another presentation at Perl Seminar New York in October 2003 prompted
1174 me to begin planning List::Compare::Functional.
1175
1176 In a November 2003 Perl Seminar New York presentation, Ben Holtzman
1177 discussed the performance costs entailed in Perl's "sort" function.
1178 This led me to ask, ''Why should a user of List::Compare pay this per‐
1179 formance cost if he or she doesn't need a human-readable list as a
1180 result (as would be the case if the list returned were used as the
1181 input into some other function)?'' This led to the development of
1182 List::Compare's unsorted option.
1183
1184 An April 2004 offer by Kevin Carlson to write an article for The Perl
1185 Journal (<http://tpj.com>) led me to re-think whether a separate module
1186 (the former List::Compare::SeenHash) was truly needed when a user
1187 wanted to provide the constructor with references to seen-hashes rather
1188 than references to arrays. Since I had already adapted List::Com‐
1189 pare::Functional to accept both kinds of arguments, I adapted
1190 List::Compare in the same manner. This meant that List::Compare::Seen‐
1191 Hash and its related installation tests could be deprecated and deleted
1192 from the CPAN distribution.
1193
1194 A remark by David H. Adler at a New York Perlmongers meeting in April
1195 2004 led me to develop the 'single hashref' alternative constructor
1196 format, introduced in version 0.29 the following month.
1197
1198 Presentations at two different editions of Yet Another Perl Conference
1199 (YAPC) inspired the development of List::Compare versions 0.30 and
1200 0.31. I was selected to give a talk on List::Compare at YAPC::NA::2004
1201 in Buffalo. This spurred me to improve certain aspects of the documen‐
1202 tation. Version 0.31 owes its inspiration to one talk at the Buffalo
1203 YAPC and one earlier talk at YAPC::EU::2003 in Paris. In Paris I heard
1204 Paul Johnson speak on his CPAN module Devel::Cover and on coverage
1205 analysis more generally. That material was over my head at that time,
1206 but in Buffalo I heard Andy Lester discuss Devel::Cover as part of his
1207 discussion of testing and of the Phalanx project
1208 (<http://qa.perl.org/phalanx>). This time I got it, and when I
1209 returned from Buffalo I applied Devel::Cover to List::Compare and wrote
1210 additional tests to improve its subroutine and statement coverage. In
1211 addition, I added two new methods, "get_unique_all" and "get_comple‐
1212 ment_all". In writing these two methods, I followed a model of test-
1213 driven development much more so than in earlier versions of List::Com‐
1214 pare and my other CPAN modules. The result? List::Compare's test
1215 suite grew by over 3300 tests to nearly 23,000 tests.
1216
1217 If You Like List::Compare, You'll Love ...
1218
1219 While preparing this module for distribution via CPAN, I had occasion
1220 to study a number of other modules already available on CPAN. Each of
1221 these modules is more sophisticated than List::Compare -- which is not
1222 surprising since all that List::Compare originally aspired to do was to
1223 avoid typing Cookbook code repeatedly. Here is a brief description of
1224 the features of these modules. (Warning: The following discussion is
1225 only valid as of June 2002. Some of these modules may have changed
1226 since then.)
1227
1228 · Algorithm::Diff - Compute 'intelligent' differences between two
1229 files/lists (<http://search.cpan.org/dist/Algorithm-Diff/>)
1230
1231 Algorithm::Diff is a sophisticated module originally written by
1232 Mark-Jason Dominus, later maintained by Ned Konz, now maintained by
1233 Tye McQueen. Think of the Unix "diff" utility and you're on the
1234 right track. Algorithm::Diff exports methods such as "diff", which
1235 ''computes the smallest set of additions and deletions necessary to
1236 turn the first sequence into the second, and returns a description
1237 of these changes.'' Algorithm::Diff is mainly concerned with the
1238 sequence of elements within two lists. It does not export func‐
1239 tions for intersection, union, subset status, etc.
1240
1241 · Array::Compare - Perl extension for comparing arrays
1242 (<http://search.cpan.org/dist/Array-Compare/>)
1243
1244 Array::Compare, by Dave Cross, asks whether two arrays are the same
1245 or different by doing a "join" on each string with a separator
1246 character and comparing the resulting strings. Like List::Compare,
1247 it is an object-oriented module. A sophisticated feature of
1248 Array::Compare is that it allows you to specify how 'whitespace' in
1249 an array (an element which is undefined, the empty string, or
1250 whitespace within an element) should be evaluated for purpose of
1251 determining equality or difference. It does not directly provide
1252 methods for intersection and union.
1253
1254 · List::Util - A selection of general-utility list subroutines
1255 (<http://search.cpan.org/dist/Scalar-List-Utils/>)
1256
1257 List::Util, by Graham Barr, exports a variety of simple, useful
1258 functions for operating on one list at a time. The "min" func‐
1259 tion returns the lowest numerical value in a list; the "max" func‐
1260 tion returns the highest value; and so forth. List::Compare dif‐
1261 fers from List::Util in that it is object-oriented and that it
1262 works on two strings at a time rather than just one -- but it aims
1263 to be as simple and useful as List::Util. List::Util will be
1264 included in the standard Perl distribution as of Perl 5.8.0.
1265
1266 Lists::Util (<http://search.cpan.org/dist/List-MoreUtils/>), by
1267 Tassilo von Parseval, building on code by Terrence Brannon, pro‐
1268 vides methods which extend List::Util's functionality.
1269
1270 · Quantum::Superpositions (<http://search.cpan.org/dist/Quan‐
1271 tum-Superpositions/>), originally by Damian Conway, now maintained
1272 by Steven Lembark is useful if, in addition to comparing lists, you
1273 need to emulate quantum supercomputing as well. Not for the
1274 eigen-challenged.
1275
1276 · Set::Scalar - basic set operations
1277 (<http://search.cpan.org/dist/Set-Scalar/>)
1278
1279 Set::Bag - bag (multiset) class
1280 (<http://search.cpan.org/dist/Set-Bag/>)
1281
1282 Both of these modules are by Jarkko Hietaniemi. Set::Scalar has
1283 methods to return the intersection, union, difference and symmetric
1284 difference of two sets, as well as methods to return items unique
1285 to a first set and complementary to it in a second set. It has
1286 methods for reporting considerably more variants on subset status
1287 than does List::Compare. However, benchmarking suggests that
1288 List::Compare, at least in Regular mode, is considerably faster
1289 than Set::Scalar for those comparison methods which List::Compare
1290 makes available.
1291
1292 Set::Bag enables one to deal more flexibly with the situation in
1293 which one has more than one instance of an element in a list.
1294
1295 · Set::Array - Arrays as objects with lots of handy methods (includ‐
1296 ing set comparisons) and support for method chaining.
1297 (<http://search.cpan.org/dist/Set-Array/>)
1298
1299 Set::Array, by Daniel Berger, now maintained by Ron Savage, ''aims
1300 to provide built-in methods for operations that people are always
1301 asking how to do,and which already exist in languages like Ruby.''
1302 Among the many methods in this module are some for intersection,
1303 union, etc. To install Set::Array, you must first install the Want
1304 module, also available on CPAN.
1305
1307 There are no bug reports outstanding on List::Compare as of the most
1308 recent CPAN upload date of this distribution.
1309
1311 Support for List::Compare is now provided by mailing list:
1312 <http://thenceforward.net/cgi-bin/mailman/listinfo/list-compare>.
1313
1314 Please report any bugs by mail to "bug-ExtUtils-Module‐
1315 Maker@rt.cpan.org" or through the web interface at
1316 <http://rt.cpan.org>.
1317
1319 James E. Keenan (jkeenan@cpan.org). When sending correspondence,
1320 please include 'List::Compare' or 'List-Compare' in your subject line.
1321
1322 Creation date: May 20, 2002. Last modification date: February 19,
1323 2006.
1324
1326 Copyright (c) 2002-06 James E. Keenan. United States. All rights
1327 reserved. This is free software and may be distributed under the same
1328 terms as Perl itself.
1329
1331 BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
1332 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
1333 WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
1334 PARTIES PROVIDE THE SOFTWARE ''AS IS'' WITHOUT WARRANTY OF ANY KIND,
1335 EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1336 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
1337 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
1338 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
1339 NECESSARY SERVICING, REPAIR, OR CORRECTION.
1340
1341 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
1342 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
1343 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
1344 TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CON‐
1345 SEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFT‐
1346 WARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
1347 INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
1348 THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER
1349 OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
1350
1351
1352
1353perl v5.8.8 2006-02-18 List::Compare(3)