On 11/08/2012 11:39 PM, Vladimir Timofeev wrote: > On Thu, Nov 8, 2012 at 10:25 PM, Jan Dubois <jand@activestate.com> wrote: >> On Thu, Nov 8, 2012 at 4:16 AM, Vladimir Timofeev <vovkasm@gmail.com> wrote: >>> Since 5.16 perl follow current locale after POSIX::setlocale. >>> Also stringification of NVs. >>> >>> But why? >>> It can lead to very subtle bugs :-( >>> >>> Example: >>> vovkasm$ perl -MPOSIX -E '$a=0.5; >>> POSIX::setlocale(POSIX::LC_ALL,"ru_RU.UTF-8"); say "$a"; >>> POSIX::setlocale(POSIX::LC_ALL,"C"); say "$a"' >>> 0,5 >>> 0,5 >>> >>> Is this desired behaviour? >> >> I would agree that this is a bug. Especially since the locale is only >> used for translating NV to PV, but not for PV to NV, so it breaks the >> IV/NV/PV transparency: >> >> $ perl -MPOSIX -E 'POSIX::setlocale(POSIX::LC_ALL,"de_DE.UTF-8"); >> $a=0.2; say "$a"+1; ' >> 1 >> $ perl -MPOSIX -E 'POSIX::setlocale(POSIX::LC_ALL,"en_EN.UTF-8"); >> $a=0.2; say "$a"+1; ' >> 1.2 > > Yes, and that is why I would like to know the original reasoning > behind these changes. > And if it is not vitally important, I would recommend to revert these changes. > >> >> Cheers, >> -Jan > > > > -- > Vladimir Timofeev <vovkasm@gmail.com> > I started looking into this, and ran into a more fundamental question. It says in perllocale.pod that locales are only paid attention to within the scope of a 'use locale'. There is no such pragma in the examples above, therefore it seems to me that the use of setlocale shouldn't affect anything. The code in the core that I'm familiar with doesn't look at locales unless under the scope of 'use locale'. Am I missing something here?Thread Previous | Thread Next