#!/usr/bin/perl my $num_in = 1234567.89; print "$num_in\n"; my $num_out = scalar reverse join "", map { s/(\d{2})\./$1,\b/; s/^(\d{1,3})$/\.$1/; $_ } (reverse sprintf("%.2f", $num_in)) =~ m/.{1,3}/g; print "$num_out\n"; my $get_text = $num_out; print "$get_text\n"; #this loses the 7 # $get_text =~ s/\.//g; # tr is similar $get_text =~ tr/.//d; #this clunky method works to remove commas # $get_text =~ s/\./ /g; # # $get_text =~ s/\s+//g; #won't work to remove spaces # $get_text =~ s/\s+//; # $get_text =~ s/\s+//; #this then works to change decimal point to . $get_text =~ tr/,/./d; # now if I try to force numeric context it fails #$get_text = $get_text + 0.00; print "$get_text\n";