Re: Comparing 2 lists

2003-07-24 Thread Mike Flannigan
Shiping Wang wrote: > ### > > foreach my $element (keys %count) { > push @union, $element; > push @{ $count{$element} > 1 ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, > $element; > > } # you have declared

Re: Comparing 2 lists

2003-07-24 Thread John W. Krahn
Mike Flannigan wrote: > > 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 @intersecti

Re: Comparing 2 lists

2003-07-24 Thread Mike Flannigan
> 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

Re: Comparing 2 lists

2003-07-21 Thread Jeff 'japhy' Pinyan
On Jul 21, awarsd said: >counter=0; >foreach $line(@list1){ >foreach $sec_line(@list2){ > if($line eq $sec_line){ >$counter++; >$new_list[$counter]=$line; >} >} >} >print @new_list; There's no reason to use $counter. Simply say push @new_list, $lin

RE: Comparing 2 lists

2003-07-21 Thread Marcos . Rebelo
%list1Hash; $list1Hash{$_}=1 foreach (@list1); foreach my $match (@list2){ push(@result, $match) if $list1Hash{$match}; } print @result; -Original Message- From: awarsd [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2003 4:35 PM To: [EMAIL PROTECTED] Subject: Re: Comparing 2 lists Hi

Re: Comparing 2 lists

2003-07-21 Thread Jeff 'japhy' Pinyan
On Jul 21, [EMAIL PROTECTED] said: >I have 2 lists of companies, not neccessarly in order, and i want to produce >a list of companies which apear in both lists. 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 arr

Re: Comparing 2 lists

2003-07-21 Thread awarsd
Hi, you have an array say list1. you have a second array say list2. counter=0; foreach $line(@list1){ foreach $sec_line(@list2){ if($line eq $sec_line){ $counter++; $new_list[$counter]=$line; } } } print @new_list; something like that -- To unsub

Comparing 2 lists

2003-07-21 Thread jonathan . musto
Hi all, Sorry i'm very new to this. I have 2 lists of companies, not neccessarly in order, and i want to produce a list of companies which apear in both lists. Eg. List 1... Macdonalds HMV Virgin Dixons Compared with List 2... HMV Flannels Currys Dixons Will output... HMV Dixons J