perl_seeker has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I already have the code to do the following, but I thought there must be some code existing already that does
it, perhaps more efficiently.

I need to open a text file in a Tk text widget window. The contents of the text file need to be tokenised into words,
punctuation and other symbols removed. This list of tokens/words(list 1) need to be compared with the words
in another text file (list 2, preferably implemented as a hash or hash slice).

For each word in list 1 which is not present in list 2, the particular word needs to be marked in the Tk text widget in
some way, for example changing the font colour of the word (from black to red, say).

(I have some code that loads a text file in a Tk text widget, saves it, etc.)

Does anyone know of any code that can be used to do the above?
Thanks in advance,
perl_seeker:)

Replies are listed 'Best First'.
Re: Perl and Perl Tk question.
by zentara (Cardinal) on Dec 23, 2004 at 12:43 UTC
    It ought to be easy to do. There are any number of ways to get a diff between 2 files, then you just need to tag the diff words with a color. The "widget demo" has a text -search demo which shows how to add color tags. Or you can do a google search for "tkdiff". You might get tcl, though.

    Here is a way to have multi-colored tags which I wrote in Tk Multicolor text-search with regex. You should easily be able to modify it so you tag words found through a diff routine.


    I'm not really a human, but I play one on earth. flash japh
Re: Perl and Perl Tk question.
by davidj (Priest) on Dec 23, 2004 at 17:47 UTC
    In order to know if there is existing code that is more efficient, we need to know how efficient your code is. If you post it, maybe some of your fellow monks can suggest ways to tweak it or give you suggestions for alternative ways of writing it.

    davidj