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;
}
All content licensed under the Creative Commons License