From: Jarkko Hietaniemi Date: Wed, 30 May 2001 22:02:21 +0000 (+0000) Subject: The regex trick wasn't a good idea. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b927632bbda90c3330f7b638ce0eed155df0b2f;p=p5sagit%2Fp5-mst-13.2.git The regex trick wasn't a good idea. p4raw-id: //depot/perl@10330 --- diff --git a/pod/perlfaq4.pod b/pod/perlfaq4.pod index 4acd3d9..0d23e24 100644 --- a/pod/perlfaq4.pod +++ b/pod/perlfaq4.pod @@ -42,17 +42,7 @@ are consequently slower. If precision is important, such as when dealing with money, it's good to work with integers and then divide at the last possible moment. For example, work in pennies (1995) instead of dollars and cents -(19.95) and divide by 100 at the end. In fact, if you are dividing by -100, you don't even need to really divide-- just split of the -fractional parts and insert the '.' (or whichever is your decimal -separator) in between, e.g. - - sub d100 { - $_[0] =~ /(.*?)(.(?:.)?)$/; - sprintf("%d.%02d", $1||0, $2); - } - -and then display all your numbers like this: C +(19.95) and divide by 100 at the end. To get rid of the superfluous digits, just use a format (eg, C) to get the required precision.