You use a hash for holding your elements to check against and use the values
within the array as a key to know whether it is a hit or not.  If unsure on
how data coming in, then make sure you use a lc or uc against your data and
the data coming in, unless CAP is different from cap.

Wags ;) ps following not tested but should be close

#!perl -w
use strict;

my %possible_matches = ('list', 1, 'of',1, 'items',1, 'to',1, 'match',1,
'against',1 ); # Hash comes in sets of two ( key/Value )


@list = qw(     imagine that there is an unknown number of elements in here
);

foreach my $MyKey (@list) {
        if ( exists $possible_matches{$MyKey} ) {
           # exists
       }else {
           # does not exist
       }
}
-----Original Message-----
From: scott lutz [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 15:02
To: [EMAIL PROTECTED]
Subject: Matching one array against another


I have a question that to me seems like it would be part of the foundation 
of Perl.

@possible_matches = qw( list of items to match against  );


@list = qw(     imagine that there is an unknown
                number of elements in here      );

foreach $list (@list) {
        # now match againt each value in @possible_matches, one-by-one,
}

Is this not possible?
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Reply via email to