> -----Original Message-----
> From: david [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 05, 2002 1:07 PM
> To: [EMAIL PROTECTED]
> Subject: Re: getting an intersection between two arrays....
> 
> 
> sounds like you want to remove all @banned from @hrefs right?
> if your arrays are small and you don't care using up a little memeory:
> 
> my @hrefs = (1..10);
> my @banned = (3..6);
> 
> my %hash;
> @hash{@a} = ();
> 
> delete @hash{@b}; #-- remove 3,4,5,6 from 1 to 10
> 
> foreach my $i (keys %hash){
>         print "$i\n"; #-- prints 1,2,7,8,9,10
> }
> 
> you will likely to lose the order of the original @hrefs as well.

You also lose any dups in @hrefs, if that matters. Something like this will
preserve the order and the dups:

   @hrefs = do { my %h; @h{@banned} = (); grep !exists($h{$_}), @hrefs }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to