Can anyone assist in explaining what the function 'commafy' is doing?
there are a few things in there i dont understand, i.e. the scalar and reverse pieces of code.
my usage of the function:
Code:
comm(sprintf("%.2f", $byviewprice{$view}))
a typical example of the value of '$byviewprice{$view}' is 501.
Code:
sub comm {
my $text = shift;
$text = reverse $text;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
if ($text eq "") {
$text = 0;
}
return scalar reverse $text;
}
www.crmpicco.co.uk
www.ie7.com