Thanks you very much for your kind help! On 10/20/05, John W. Krahn <[EMAIL PROTECTED]> wrote: > Franklin wrote: > > Hi: > > Hello, > > > I am a real beginner of perl. after looking for Internet for serveral > > hours, I still can't find the answers for my problem. My question is: > > Which function I can use to get 2 digits after point for a variable? > > For example, for $j=2.56789, how can I get the very first two digits > > after points,ie, I just want to get 2.56. > > $ perl -le'$j = 2.56789; print $j; $j = int( $j * 100 ) / 100; print $j;' > 2.56789 > 2.56 > > $ perl -le'$j = 2.56789; print $j; $j =~ s/(?<=\.\d\d)\d*//; print $j;' > 2.56789 > 2.56 > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > >
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>