Similar to above:
my $num = reverse shift;
$num =~ s/(\d{3})/$1,/g;
$num = reverse $num;
Correction: The code I supplied places a comma at the front if the number of digits is divisible by 3. Need to append:
$num =~ s/^,//;Now its gone from ugly to really ugly - apologies