Re: find words not in an array
From: Jürgen Exner (jurgenex_at_hotmail.com)
Date: 03/28/05
- Next message: Acebravo: "About Encryption Question"
- Previous message: ssmith: "Re: find words not in an array"
- In reply to: r: "find words not in an array"
- Next in thread: mbstevens: "Re: find words not in an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Mar 2005 06:18:17 GMT
r wrote:
> if I have 2 arrays, @wordlist and @testlist, how can I create a third
> array that contains the words from @testlist that are not common to
> @wordlist?
> I thought I might use grep but can't figure it out.
No, grep isn't quite the right tool. For questions like that a hash is
usually the datastructure of choice.
In this particular case you may want to start with the "perldoc -q
intersection". This FAQ computes the symmetric difference, so you will have
to modify the answer slightly.
Or you simply grab the proper set module from CPAN.
jue
- Next message: Acebravo: "About Encryption Question"
- Previous message: ssmith: "Re: find words not in an array"
- In reply to: r: "find words not in an array"
- Next in thread: mbstevens: "Re: find words not in an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|