[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-admin
Subject:    Re: Comparing an array to an array
From:       "Glenn Meyer" <gmeyer9 () us ! ibm ! com>
Date:       2002-01-28 14:09:59
[Download RAW message or body]

That is how I do it also - compare an array against a hash (my base line of
known items)....

foreach $users (@users) {                # Loops through array of user IDs
from server (the array is my list in question)
     $users =~ tr/[A-Z]/[a-z]/ ;              # Converts each to all lower
case
     if (! exists $actions{$users}) {         # Compare each to hash to see
if they exist in hash (the hash is my "known good list")
          push(@badusers, $users); # If not in authorized hash, pushes to
baduser array
     }
}

Glenn Meyer   -  gmeyer9@us.ibm.com
IBM Global Service
Content Hosting Systems Administrator




                                                                                      \
                
                    Lomker Michael <mlomker@mpr.org>                                  \
                
                    Sent by:                                    To:     "Satelle, \
                StevenX" <stevenx.satelle@intel.com>                 
                    perl-win32-admin-admin@listserv.Activ       cc:     \
                perl-win32-admin@listserv.ActiveState.com                      
                    eState.com                                  Subject:     Re: \
                Comparing an array to an array                        
                                                                                      \
                
                                                                                      \
                
                    01/27/2002 10:56 AM                                               \
                
                                                                                      \
                
                                                                                      \




> Does anyone know how to do this? I dont mean the amount of variables in
> it.
> I mean take list "a" and compare each element  to each element of list
> "b"
> and if they match do something.

There is undoubtedly a way to use the CMP operator on a pair of arrays,
but I found it  easier to convert one of the arrays to a hash and check
for the existence of the key.

_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin



_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic