Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by Khen1950fx (Canon)
on Jul 11, 2013 at 23:20 UTC ( [id://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?

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-19 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found