Stuart Clark wrote: > Hi, > I am trying to move the decimal point 2 places to the the left. > > Eg : To make 4536233 into 45362.33 > > I tried this > $total = "4536233"; > $total = sprintf("%0.2f",$total); > print "$total"; > But I get this > 4536233.00 > > Can anyone help please > > Regards > Stuart Clark
hm let me take a shot at this one my $digits = 4536233; $digits =~ m/(\d\d)$/; #I was going to inline this, but not sure of return value splice ( split ( //, $digits ), -2, 2, ( "." . $1) ) ); that should work, probably not worth it thought (I just opened the llama book and picked the first function that looked good and worked from that ^.^ anyway, the reason your example didn't work is because sprintf will truncate decimals from a floating point number. printf("%5.2f",$varname); #prints 123.12 if the var containted 123.1231525 since you had created a var containing integers (actually you created a string, it just turned it into numbers on demand), it didn't have anything to add for the decemil part. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]