in reply to Re: Comparing two variables from different loops
in thread Comparing two variables from different loops
You need just one hash. Something like this
my %ids; my @orig_service_ids = (3,1,4,9,7,12); # this represents your first while ($sth->fetch) loop for my $id (@orig_service_ids) { $ids{$id} = 1; # instead of '1', you could also assign something else as value, # e.g. an anonymous array [...], or an anonymous hash {...}, to # store associated data, which you could then retrieve later... } # ... my @dest_service_ids = (1,5,8,11,7,2,9); # this represents your second while ($sth->fetch) loop for my $id (@dest_service_ids) { if (exists $ids{$id}) { print "ID $id exists in both origin and destination set\n"; # ... } }
|
|---|