Hello Monks,

I have a function that Compares 2 arrays and updates intersections of arrays and updates seconds arary only elements. My referencing for @bonly is getting screwed up. Can some one tell me why it is the case?

# Calling deDuppedArray(\@currentListing, \@previousListing, \@bonly, \@isec_plu +s_bonly);
sub deDuppedArray { my $a_ref = shift; # reference to input array A my @a = @$a_ref; # input array A my $b_ref = shift; # reference to input array B my @b = @$b_ref; # input array B my $bonly_ref = shift; # input array Bonly my @my_bonly = @$bonly_ref; # input array Bonly my $isec_plus_bonly_ref = shift; # input array isec_plus_bonly my @my_isec_plus_bonly = @$isec_plus_bonly_ref; # input array isec +_plus_bonly my (%Aseen, %Bseen) = (); @Aseen{@a} = (); # lookup table @Bseen{@b} = (); # lookup table my (%count, @isec, @diff, @union, @aonly) = (); @my_bonly = (); # create null arrays foreach my $e (@a, @b) { $count{$e}++ } # put all items in hash ta +ble foreach my $e (keys %count) { # interate over each key of hash table push(@union, $e); # keys of hash table = union if ($count{$e} == 2) { push @isec, $e; # seen more than once = intersection } else { push @diff, $e; # seen once = difference push(@aonly, $e) unless exists $Bseen{$e}; # seen once + f +rom A = Aonly push(@my_bonly, $e) unless exists $Aseen{$e}; # seen once ++ from A = Aonly } } @my_isec_plus_bonly = ( @isec, @my_bonly); }

In reply to Referencing in Function not working correctly. by mr_p

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.