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

I have a GUI application running on Tk. Up until today it worked nicely on Strawberry 5.32.

After upgrading to Strawberry 5.40 and applying the Tk patch Tk-804.036_001, the widget demo works as expected but my application does not.

The thing that no longer works is that floating point numbers are suddenly represented with comma instead of period, which seems to be a side effect of calling Tk::MainWindow->new().

As a consequence of this, all my floating point (and there's a lot) are now treated as integers, making e.g. 1/0.1 yield div by zero.

use Tk; $x = 1.2; $sq = $x * $x; print "Before Tk call $x, $sq\n"; $Window = MainWindow->new(); print "After Tk call $x, $sq\n";

yields(notice the change in comma separator)...

Before Tk call 1.2, 1.44 After Tk call 1,2, 1,44

When using the debugger and entering a simple "x 1.2", a single 1 is returned. x 1/0.1 yields division by zero

Any suggestions on what ty try next grately appreciated. I would hate to have to go back to 5.32.

Replies are listed 'Best First'.
Re: Strawberry 5.40 Tk affects floating point comma separator (perllocale)
by LanX (Saint) on Jan 02, 2025 at 13:48 UTC

      Indeed, the locale was the problem. Funny thing is that my swedish locale seemed to be ineffective until the call to Tk, which caused it to take effect. Setting locale to english at the start of the program solved it all.

      Thanks for you quick response!

      use POSIX qw(setlocale locale_h LC_ALL); setlocale(LC_NUMERIC, 'en_US.UTF-8');
        > Setting locale to english at the start of the program solved it all.

        If possible, I'd try putting it into a BEGIN block.

        And in case you want it everywhere in Perl, but don't wanna change your system's locale: you can also tweak your Perl installation to do it globally for all programs started.

        > Thanks for you quick response!

        Thanks for the feedback! :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery