final (?) fix for locale problem (RT #41285)

Instead of testing the value of the env variables, use
POSIX::setlocale to get the effective value of the LC_CTYPE
locale (the only one effecting tr operation).

For the workaround on top of the script, add also LC_CTYPE
to the list of env variables explicitely set to C.

Also, setting the env variables must happen in a BEGIN{}
block, otherwise things are too late.
Merge pull request #1 from eserte/RT-41285

better fix for locale problem (RT #41285)