diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-30 06:43:48 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-30 06:43:48 +0000 |
commit | f6f049eb28180b2e51f8dac70ef345ce889c847f (patch) | |
tree | cd9908734bfe4677120b31f9a12b8ba3a603da81 /LedgerSMB/Num2text.pm | |
parent | 32aef327a1e3b769c0c08c6b1786daaa841e017b (diff) |
Whitepace cleanup on Menu, Mailer, Inifile, and Num2text
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@173 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Num2text.pm')
-rwxr-xr-x | LedgerSMB/Num2text.pm | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/LedgerSMB/Num2text.pm b/LedgerSMB/Num2text.pm index e8093ab5..4cb79fec 100755 --- a/LedgerSMB/Num2text.pm +++ b/LedgerSMB/Num2text.pm @@ -33,9 +33,9 @@ sub init { - my $self = shift; + my $self = shift; - %{ $self->{numbername} } = + %{ $self->{numbername} } = (0 => 'Zero', 1 => 'One', 2 => 'Two', @@ -75,90 +75,90 @@ sub init { sub num2text { - my ($self, $amount) = @_; + my ($self, $amount) = @_; - return $self->{numbername}{0} unless $amount; + return $self->{numbername}{0} unless $amount; - my @textnumber = (); + my @textnumber = (); - # split amount into chunks of 3 - my @num = reverse split //, abs($amount); - my @numblock = (); - my @a; - my $i; + # split amount into chunks of 3 + my @num = reverse split //, abs($amount); + my @numblock = (); + my @a; + my $i; - while (@num) { - @a = (); - for (1 .. 3) { - push @a, shift @num; - } - push @numblock, join / /, reverse @a; - } + while (@num) { + @a = (); + for (1 .. 3) { + push @a, shift @num; + } + push @numblock, join / /, reverse @a; + } - while (@numblock) { + while (@numblock) { - $i = $#numblock; - @num = split //, $numblock[$i]; + $i = $#numblock; + @num = split //, $numblock[$i]; - if ($numblock[$i] == 0) { - pop @numblock; - next; - } + if ($numblock[$i] == 0) { + pop @numblock; + next; + } - if ($numblock[$i] > 99) { - # the one from hundreds - push @textnumber, $self->{numbername}{$num[0]}; + if ($numblock[$i] > 99) { + # the one from hundreds + push @textnumber, $self->{numbername}{$num[0]}; - # add hundred designation - push @textnumber, $self->{numbername}{10**2}; + # add hundred designation + push @textnumber, $self->{numbername}{10**2}; - # reduce numblock - $numblock[$i] -= $num[0] * 100; + # reduce numblock + $numblock[$i] -= $num[0] * 100; - } + } - $numblock[$i] *= 1; + $numblock[$i] *= 1; - if ($numblock[$i] > 9) { - # tens - push @textnumber, $self->format_ten($numblock[$i]); - } elsif ($numblock[$i] > 0) { - # ones - push @textnumber, $self->{numbername}{$numblock[$i]}; - } + if ($numblock[$i] > 9) { + # tens + push @textnumber, $self->format_ten($numblock[$i]); + } elsif ($numblock[$i] > 0) { + # ones + push @textnumber, $self->{numbername}{$numblock[$i]}; + } - # add thousand, million - if ($i) { - $num = 10**($i * 3); - push @textnumber, $self->{numbername}{$num}; - } + # add thousand, million + if ($i) { + $num = 10**($i * 3); + push @textnumber, $self->{numbername}{$num}; + } - pop @numblock; + pop @numblock; - } + } - join ' ', @textnumber; + join ' ', @textnumber; } sub format_ten { - my ($self, $amount) = @_; + my ($self, $amount) = @_; - my $textnumber = ""; - my @num = split //, $amount; + my $textnumber = ""; + my @num = split //, $amount; - if ($amount > 20) { - $textnumber = $self->{numbername}{$num[0]*10}; - $amount = $num[1]; - } else { - $textnumber = $self->{numbername}{$amount}; - $amount = 0; - } + if ($amount > 20) { + $textnumber = $self->{numbername}{$num[0]*10}; + $amount = $num[1]; + } else { + $textnumber = $self->{numbername}{$amount}; + $amount = 0; + } - $textnumber .= " ".$self->{numbername}{$amount} if $amount; + $textnumber .= " ".$self->{numbername}{$amount} if $amount; - $textnumber; + $textnumber; } |