I hate to say it as the regex way is kinda cool, but
$y = int($x * 100)/100;
is much faster, at least on my machine.
even
$x = sprintf("%.2f", int($y * 100)/100);
is marginally faster and pads the output to two decimal points..
John Moon wrote:
> One way to do it ...
>
> perl -e '$x=1234.5678; ($y)=$x=~/(\d*\.{0,1}\d{0,2})/;print $y ."\n";'
>
> -----Original Message-----
> From: Thomas Jakub [mailto:[EMAIL PROTECTED]]
> Sent: July 10, 2001 15:44
> To: [EMAIL PROTECTED]
> Subject: dropping off a few decimal points
>
> okay... so how do I drop of all but two decimal
> points in perl?
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/