Perlfunc: Commify

Simple perl function to add commas to a long number to make it more readable.

sub commify {
    # commify a number. Perl Cookbook, 2.17, p. 64
    my $text = reverse $_[0];
    $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
    return scalar reverse $text;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 18.219.63.90
To prevent spam please submit by clicking the kitten: