sub commafy { my $num = reverse shift; my @threes = $num =~ /(.{1,3})/g; return scalar reverse join ',', @threes; }