in reply to PAR and Tk

What versions of perl, PAR, Tk?
Example to try?
Screenshot?
I encountered problem with character encodings and Tk804.025, but that's marked as resolved (although that version of PAR hasn't hit CPAN yet, its at http://p4.elixus.org/snap/PAR.tar.gz).

update: my guess would be it's the same problem, so you should try the newest PAR.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: PAR and Tk
by nornagon (Acolyte) on May 16, 2004 at 11:46 UTC
    Ah. I was using the ppm version (version 0.75) *downloads*

    Perl version: ActiveState 5.8
    Tk version: 800.025

    Ok, it nmakes fine, then when I nmake test it gives me a bunch of error messages. Mostly 'Can't locate hidden_print.pm or hidden_print_caller.pm'

    But in the end it doesn't complain too much.

    Now to test...

    Aaand... same result. Character encoding problems.

    Code in <readmore>

    All I did was pp dict.pl, then run a.exe and I get the char encoding.

      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:
      sub get_words { my $dict = Net::Dict->new('dict.org'); my $term = $wordbox->get; my $h = $dict->define($term); my $result; my $n = 0; #(update: left line this out earlier, but see below) foreach my $i (@{$h}) { my ($db, $def) = @{$i}; print join "", "$db: $term:\n", map { sprintf("%.2x $_\n",ord( +)) } split( //, $def ); $list->insert('end', "$db: $term"); $defs[$n] = $def; $n++; } }
      (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)

        Um, a problem. Either 1) I don't know what diff is, or 2) it's a unix/linux program, and I'm running a win32 machine =/

        No problems, Net::Dict is really easy :)

        {update}: Ok, I added in the get_words sub you gave me, and the output is the same for the compiled and interpreted versions. However, actually viewing the characters is still a problem.