Thursday 3 June 2010

Thrilling perl problems part #3

So I've got myself an array called @book which is a list of all the words in a text file, essentially my original text file split on whitespace. That was difficult enough to do satisfactorily, but now my next task is to create an array called @uniques, which is a list of all the unique words in @book.

In Python doing that was easy, but in perl, I'm running into problems as there is no 'in' qualifier, that is, I can't just say "foreach $word ( @book ); if $word not in @uniques; push @uniques, $word"

So instead I'm thinking I need to go through each $book in @book and compare it to each $uniques in @uniques, then have some kind of flag it waves if it doesn't match to tell it to add the word to the unique word list.

Christ, you'd think sort of this word be easy, but no no.
Sent using BlackBerry® from Orange

No comments:

Post a Comment