in reply to please explain print/say behavior with setlocale
Localization (or more precisely, LC_NUMERIC here) applies to numeric values being output. Stringification, OTOH, as it happens in something like print 1/2 . "\n" before outputting the value, isn't always subject to localization* ... And when you write print "1/2\n" etc., it's not represented as a number in the first place.
___
* update: interpolation and concatenation of numeric values stored in a variable apparently does localize:
setlocale LC_NUMERIC, "german"; $n = 1/2; print "$n\n"; # 0,5 print $n . "\n"; # 0,5 print 1/2 ."\n"; # 0.5
My guess would be this has to do with compile-time vs. run-time effects, i.e. the 1/2 in 1/2 . "\n" is being processed at compile-time without the locale setting having been modified yet, unless you put the setlocale in a BEGIN {} block...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: please explain print/say behavior with setlocale
by wwe (Friar) on Mar 30, 2010 at 11:40 UTC | |
|
Re^2: please explain print/say behavior with setlocale
by wwe (Friar) on Mar 30, 2010 at 11:54 UTC | |
by almut (Canon) on Mar 30, 2010 at 11:59 UTC | |
by wwe (Friar) on Mar 30, 2010 at 12:11 UTC |