Ronen Kfir wrote:
> Hi,
>
> I'm working on windows XP. ActiveState Perl 5.8 is installed.
>
> This code is taken from "learning Perl\ Schwartz & Phoenix.
>
>
>
> sub big_money {
>
> $number = sprintf " %.2f", shift @_;
>
> 1 while $number =~ s/^(-?\d+) (\d\d\d) /$1, $2/;
>
> $number=~ s/^(-?)/$1\$;
>
> $number;
>
> }
>
>
>
> In the book they write the no. 12345678.90 as the no. of example. What I
> miss is how I include this no. in the script. How do I make script look
> at this no.?
Please post to these lists in plain text.
use strict;
my $result = big_money (12345678.90);
print $result, "\n";
exit;
sub big_money {
my $number = sprintf " %.2f", shift;
1 while $number =~ s/^(-?\d+)(\d\d\d)/$1,$2/;
$number =~ s/^(-?)/$1\$;
}
__END__
That's pretty much the same as the commify routine:
sub commify {
local $_ = shift;
return $_ if tr/0-9/0-9/ < 4;
1 while s/^(-?\d+)(\d{3})/$1,$2/;
return $_;
}
Here are some beginner lists also:
[EMAIL PROTECTED] via http://lists.perl.org/
http://groups.yahoo.com/group/perl-beginner
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs