in reply to Re^2: A locale independent sprintf?
in thread A locale independent sprintf?
Using y/,/./, instead of s/,/./, should be faster (see "perlperf: Search and replace or tr"). Obviously, I can't say whether it will be noticeably or usefully faster.
You may want the 'r' modifier. Here's a somewhat fudged example for demonstration purposes:
$ perl -E 'say sprintf("3,%d", 14)' 3,14 $ perl -E 'say sprintf("3,%d", 14) =~ y/,/./' Can't modify constant item in transliteration (tr///) at -e line 1, at + EOF Execution of -e aborted due to compilation errors. $ perl -E 'say sprintf("3,%d", 14) =~ y/,/./r' 3.14
If you try this, I'd be interested in what sort of speed improvement you see.
— Ken
In Section
Seekers of Perl Wisdom