grimoire/perl/commas.pl

20 lines
288 B
Perl
Executable File

#!/usr/bin/env perl
foreach $arg (0..$#ARGV) {
my $num = int($ARGV[$arg]);
my $fmt = "", $cnt = 0;
while($num > 0) {
$fmt = ($num % 10) . $fmt;
if(++$cnt % 3 == 0 and $num >= 10) {
$fmt = "," . $fmt;
}
use integer;
$num /= 10;
}
print "$fmt\n";
}