I'm comparing multiple lists with List::Compare repeatedly without creating a new List::Compare object for each new comparison. It appears that List::Compare is returning the result of the first comparision.

#!/usr/bin/perl -w use strict; use List::Compare; my @one = qw( 384 425 ); my @two = qw( 384 425 466 507 548); my @three = qw( 466 507 ); my @four = qw( 666 999 ); my $lc = List::Compare->new( \@one, \@two ); my @intersection = $lc->get_intersection; print "Out 1: @intersection\n"; $lc->new( \@three, \@two ); @intersection = $lc->get_intersection; print "Out 2: @intersection\n"; $lc->new( \@four, \@two ); @intersection = $lc->get_intersection; print "Out 3: @intersection\n";
Here's my output:
Out 1: 384 425 Out 2: 384 425 Out 3: 384 425
It should look like this:
Out 1: 384 425 Out 2: 466 507 Out 3:
Is this a bug? I didn't see it in the documentation for List::Compare, but do I have to flush the lists out of the List::Compare object first? Or do I have to create a new object for each new comparision.

Edit:
Perl version = 5.8.7
List::Compare version = 0.32

In reply to Bug in List::Compare or User Error? by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.