Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hrm. I could see character encoding being an issue if you were looking up dictionary entries in some language other than English, but since you're not doing that, you may need to add some debugging output, so you can compare the "original" output (via "perl your-tk-script.pl") against the "compiled" output. Changing "get_words" to something like this might be instructive:
(also comment out the "print" statement in "get_def" -- you don't need that one anyway) When you run each version of the script (interpreted and compiled), get the same term for each run (e.g. "autotelic" -- my favorite word -- which has a mercifully short output), redirect stdout to a distinct file, then diff the two files. This will tell you at least two things: (1) whether you're getting the same number of characters from each version, and (2) whether there is any systematic bit-wise relation between the characters of the two versions (e.g. for some reason, the compiled version might just be setting the high bit of each character, though I can't imagine how this would come about). Apart from that, your code has a problem when I try to put in a second term for definition: in get_word, you reset the array index "$n" for the listbox contents to zero, but you don't remove the prior contents of the listbox. I would suggest that you declare a global index counter for @defs (e.g. put my $ndefs = 0; at the top, and use $ndefs instead of $n in get_words), and never set it back to zero. That way, a user can have multiple terms in the listbox at the same time. (Then you might need a button to delete selected items from the listbox, and/or clear the listbox contents.) Thanks for posting your code -- it was my first real introduction to Net::dict, and I could have a lot of fun with that... (updated the title to reflect the name of the thread) In reply to Re: Re: Re: PAR and Tk
by graff
|
|