develooper Front page | perl.beginners | Postings from January 2002

Re: decimal point

Thread Previous | Thread Next
From:
Leon
Date:
January 28, 2002 16:19
Subject:
Re: decimal point
Message ID:
001e01c1a8e0$c3a20340$a54ea9cb@S7575530
Try this;
my $total = "4536233";
$total =~s/(.+)(\d{2})/$1.$2/;
print $total;

----- Original Message ----- 
From: "Stuart Clark" <sc@spacelink.com.au>
To: "Perl List" <beginners@perl.org>
Sent: Sunday, January 27, 2002 5:56 PM
Subject: decimal point


> 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



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About