Hallo
Willst du das wirklich?
Brauchst du das für die USA?In Deutschland wäre:
#!/usr/bin/perl
use strict;
use warnings;sub _format_money($);
my $cash = '123456789.12';
my $formated = _format_money($cash);
print "$formated\n";
sub _format_money($){
my $val = shift;
return undef unless(defined $val);
my($full,$rest) = split(/\./,$val);
$rest ||= '00';
1 while $full =~ s/^([-+]?\d+)(\d{3})/$1.$2/;
return $full . ',' . $rest;
}
__END__
ok, in Amiland
#!/usr/bin/perl
use strict;
use warnings;sub _format_money($);
my $cash = '123456789.12';
my $formated = _format_money($cash);
print "$formated\n";
sub _format_money($){
my $val = shift;
return undef unless(defined $val);
my($full,$rest) = split(/\./,$val);
$rest ||= '00';
1 while $full =~ s/^([-+]?\d+)(\d{3})/$1,$2/;
return $full . '.' . $rest;
}
__END__
das ergibt dann:
kristian@under-the-sky:~/cgi-bin/qed> perl format_money.pl
123.456.789,12
für Europa und
kristian@under-the-sky:~/cgi-bin/qed> perl format_money.pl
123,456,789.12
für drüben.
Gruß Kristian
Datum: 04.11.2004-17:35
