Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Perl, Gtk2 and locale — a bit of a mess

by Khen1950fx (Canon)
on Jul 11, 2013 at 23:20 UTC ( #1043834=note: print w/ replies, xml ) Need Help??

in reply to Perl, Gtk2 and locale — a bit of a mess

It don't see it as a problem with locales. For example, try this:

#!/usr/bin/perl -l use strict; use warnings; my $num = 123.456; str($num); sub str { my ($want_num, $width) = @_; $width = '000'; $want_num =~ tr/./,/; $want_num = print "$want_num$width"; }
Does that work for you?

Comment on Re: Perl, Gtk2 and locale — a bit of a mess
Download Code
Replies are listed 'Best First'.
Re^2: Perl, Gtk2 and locale — a bit of a mess
by Ralesk (Pilgrim) on Jul 12, 2013 at 09:46 UTC

    I'm not even sure what you're trying to achieve here.

    • Call str with one argument, but assign @_ to two arguments, thus rendering the second one undef
    • Then you assign to the second var anyway. Fine, I guess, but I would have done something like
      sub str { my ($want_num) = @_; my $width = '000'; # ...
    • Then you replace periods in the string representation of 123.456 (which could be "123,456" or even "١٢٣٫٤٥٦" by this time) with commas, resulting in not much.
    • And then print whatever the replaced result is (let’s say "123,456") concatenated with "000" (why is that even called ‘width’?), resulting in an output of 123,456000.
    • Then you put the return value of that print in $want_num for not much reason, as print returns true on a successful print, and the value doesn’t escape the subroutine anyway.
    • str and thus the whole program then returns true after printing the above value.

    Pray tell, what did you want to achieve?

      (I am not at all surprised that this never received further comments :3)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043834]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-11-27 22:52 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (734 votes), past polls