Date: Mon, 16 Jul 2001 17:33:24 +0100
From: Jasper McCrea <jmccrea@guideguide.com>
Subject: Re: ARRAYS: find common values
Message-Id: <3B531754.7943006@guideguide.com>

Jasper McCrea wrote:
> 
> Wali Haidri wrote:
> >
> > I want to out put the common values in the two arrays below. Following
> > code does work but it is very slow.  I hope somebody can suggest a
> > better way.
> 
> isn't this an FAQ. ie use a hash.
> 
> # haven't tested this, and am assuming (probably correctly :) )
> # that uc works on $_
> my %users2 = map { uc => 1 } @users2;
> 
> foreach my $user (sort { $a cmp $b} map { uc } @users) {
>   push @finalusers, $user if $users2{$user};
> }
> 
> return @finalusers;
> 

Don't know what I was thinking.

my %users2 = map { uc => 1 } @users2;
my @final = grep { $users2{$_} } sort { $a cmp $b} map { uc } @users;
return @final;

:)

Jasp
not sure if you'll want to look up map and grep in camel, Wali, but I'm
guessing so.
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


