Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] printing out nicely formatted large numbers

Expand Messages
  • Shawn Hirn
    ... This is awesome! It works perfectly. Thank you!
    Message 1 of 3 , Feb 24, 2006
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, Victor Bouffier <victor@...> wrote:
      >
      > There is a great recipe from the Perl Cookbook to do just that. The
      > script is the following:
      >
      > sub commify {
      > my $text = reverse @_[0];
      > $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
      > return scalar reverse $text;
      > }
      >
      > To use it:
      >
      > print commify(1234567)
      > 1,234,567
      >
      > I have that piece of code on a personal scripts module I keep handy.

      This is awesome! It works perfectly. Thank you!
    Your message has been successfully submitted and would be delivered to recipients shortly.