> Subject: Re: Comparing 2 lists > Date: Mon, 21 Jul 2003 10:40:25 -0400 (EDT) > From: Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> > Reply-To: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: [EMAIL PROTECTED] > > This is in the FAQ -- if you type 'perldoc -q intersection', you'll get an > answer from the FAQ about finding the intersection of two arrays.
Newbie here. I'm trying to experiment with this code in FAQ4. I'd like to fix line 12 of this code first: use strict; use warnings; my @array1 = ("a","b","c","d","e","f","g"); my @array2 = ("h","b",'c',"i","j","k","g"); my @union = my @intersection = my @difference = (); my %count = (); foreach my $element (@array1, @array2) { $count{$element}++ } foreach my $element (keys %count) { push my (@union, $element); push my (@{ $count{$element} > 1 ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }), $element; #<<<THIS IS LINE 12 } print "@intersection,\n\n\n"; print "@difference,\n\n\n"; print "@union,\n\n\n"; # another print statment telling the reader what to do next print "Press <ENTER> to continue..."; # Perl waits at these brackets for user input <> There is apparently something wrong with: push my (@{ $count{$element} > 1 ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }), $element; It gives the warning or error of: "Use of uninitialized value in numeric gt (>) at compare.pl line 12. After I fix this simple? problem, then I need to understand the code and get it to work right :-) Mike Flannigan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]