Pete Sergeant writes:
> http://www.perldoc.com/perl5.6.1/pod/perlfaq5.html#How-can-I-output-my-numbe
> rs-with-commas-added-
>
> Sucks. The code there is not easily understandable to most people I would
> imagine are reading it. Perhaps someone would like to rewrite the examples
> to be somewhat more understandable and better programming practice.
The FAQ presents solutions to problems, not tutorials in how to
program. I have no idea what you mean about incomprehensible code.
How would you rewrite this to reflect "better programming practice"?
sub commify {
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
return $_;
}
Thanks,
Nat