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

Dear Monks, I want to use the bignum module within a Tk application but the script does not run and returns a cryptic error message. The problem only occures, if I define width of an entry widget. Without using bignum everything's fine...
#!/usr/bin/perl -w use Tk; use bignum; $mw=MainWindow->new(); $mw->Entry(-width=>10)->pack(); MainLoop;
Any ideas? I'm using strawberry perl version 5.12.1 The error message is: '|; two special characters and two smilies' isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line 205. at c:/test.pl line 6

Replies are listed 'Best First'.
Re: Problems with Tk and bignum
by wwe (Friar) on Mar 24, 2011 at 13:59 UTC
    Hi Microcebus, i can confirm your observation using Windows XP/StrawberryPerl 5.12. There is a message stating xyz isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line 205.. The most interesting thing the message is different according to which pragma you are using in your script.

    I'm not sure character encoding remains correct but I try to post some messages:

    # no pragma active 'Lî' isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line + 205. # use strict active 'ï' isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line + 205. # use strict # use warnings are active: '\ï' isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line + 205. # use strict, # use warnings and # use diagnostics are active 'ÔXª' isn't numeric at c:/strawberry/perl/site/lib/Tk/Widget.pm line 2 +05.
    the output is allways the same for the same set of pragmas. The script works fine without use bignum for me.

    P.S: special character in the posting are the same as they are displayed!

Re: Problems with Tk and bignum
by papidave (Pilgrim) on Mar 24, 2011 at 13:59 UTC
    It's hard to say for certain what the cause is for your "cryptic error", since you didn't include it with the question. Fortunately, my openSuSE 11.1 box has both bignum and Tk available on it, and when I run your code (with use strict ;-) ) I do see _an_ error which may or may not be applicable:
    Assertion ((svtype)((_svi)->sv_flags & 0xff)) >= SVt_PV failed: file " +objGlue.c", line 307 at /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linu +x-thread-multi/Tk/Widget.pm line 205. at ./foo.pl line 9
    This appears to be failed assert from Tk. My best guess is that the integer width constant is being translated into a bignum, and that Tk doesn't like it. Question: do you really need seamless big integers, or would it be sufficient to specify a few variables as big numbers with a module like Math::BigInt?
Re: Problems with Tk and bignum
by jellisii2 (Hermit) on Mar 24, 2011 at 13:49 UTC
    This code runs without error (or output, for that matter. It doesn't even render the main window) on ActivePerl 5.10 for win32. What is the error and what version of perl are you using?

    edit: I'm a dork. I was able to reproduce this error. Interestingly, putting the width in single quotes sidesteps the problem.