If you are implying right alignment, then just put a minus sign before
the formatting instruction.

$time = sprintf("%-0.2f", ($time * 2));

-- Rex

On 8/17/05, Vineet Pande <[EMAIL PROTECTED]> wrote:
> I mean:
> 
> 0.0      0.00
> 0.4     60.37
> 0.8    106.29
> 1.2    140.56
> 1.6    168.75
> 2.0    186.37
> 2.4    207.82
> 
> rather than
> 0.0    0.00
> 0.4    60.37
> 0.8    106.29
> 1.2    140.56
> 1.6    168.75
> 2.0    186.37
> 2.4    207.82
> 
> may be sth to do with sprintf, but how to impose it on selected fields..
> 
> 
> >From: Rex Rex <[EMAIL PROTECTED]>
> >To: Vineet Pande <[EMAIL PROTECTED]>
> >Subject: Re: converting to FLOATING_POINT..
> >Date: Wed, 17 Aug 2005 11:49:13 -0400
> >
> >I am afraid, I didn't get your question. "Decimals under decimals??"
> >
> >On 8/17/05, Vineet Pande <[EMAIL PROTECTED]> wrote:
> > > Thanks Rex:
> > > Please help me in knowing one more related thing. I have from this
> >script of
> > > mine an output like this:
> > > 0.0    0.00
> > > 0.4    60.37
> > > 0.8    106.29
> > > 1.2    140.56
> > > 1.6    168.75
> > > 2.0    186.37
> > > 2.4    207.82
> > > 2.8    225.45
> > > 3.2    235.88
> > > 3.6    245.55
> > > 4.0    250.61
> > > 4.4    260.06
> > > 4.8    264.60
> > > 5.2    271.11
> > > 5.6    272.90
> > > 6.0    275.62
> > > 6.4    283.33
> > > 6.8    283.55
> > > 7.2    284.58
> > > 7.6    285.22
> > > 8.0    287.51
> > > 8.4    290.38
> > > 8.8    294.09
> > > 9.2    297.01
> > > 9.6    296.16
> > > 10.0    291.57
> > > 10.4    292.88
> > > 10.8    297.28
> > > 11.2    301.13
> > >
> > > I want to see it formatted more beautifully, i.e. decimals under
> >decimals.
> > > How do we get that. My script is:
> > >
> > > use strict;
> > > use warnings;
> > >
> > > my $mdout_file = "mdout.txt";
> > >
> > > my $mdout_xtemp_file = "temp.txt";
> > >
> > >
> > > open IN, $mdout_file or die;
> > > open OUT, ">$mdout_xtemp_file" or die;
> > >
> > >
> > > while (<IN>)
> > >
> > >                       {
> > >
> > >                   if ($_ =~ ( /TEMP/ ))
> > >
> > >                             {
> > >
> > >                             my $time = (substr($_, 30, 14));
> > >                             $time =~ s/\s//g;
> > >                             my $temp = (substr($_, 53, 10));
> > >                             $temp =~ s/\s//g;
> > >
> > >                             $time = sprintf("%0.1f", ($time * 2));
> > >
> > >
> > >                             foreach ($time)
> > >                               {
> > >                             print OUT $time ;
> > >                             print OUT "    ";
> > >                                     foreach ($temp) {
> > >                                        print OUT $temp;
> > >                                        print OUT "\n";
> > >                                                     }
> > >                               }
> > >
> > >                             }
> > >
> > >                       }
> > >
> > > Thanks again!
> > > Cheers
> > > v
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > >From: Rex Rex <[EMAIL PROTECTED]>
> > > >To: Vineet Pande <[EMAIL PROTECTED]>
> > > >CC: beginners@perl.org
> > > >Subject: Re: converting to FLOATING_POINT..
> > > >Date: Wed, 17 Aug 2005 11:14:02 -0400
> > > >
> > > >Replace,
> > > >
> > > >$time = ($time * 2.0);
> > > >
> > > >to
> > > >
> > > >$time = sprintf("%0.2f", ($time * 2));
> > > >
> > > >That should do it.
> > > >
> > > >perldoc -f sprintf
> > > >
> > > >-- Rex
> > > >
> > > >On 8/17/05, Vineet Pande <[EMAIL PROTECTED]> wrote:
> > > > > Hi:
> > > > >
> > > > > In the following piece of script, I would like to convert the $time
> > > >after *
> > > > > by 2.0 to floating point, for instance i want 0*2 to be printed as
> >0.0;
> > > >How
> > > > > to do that?
> > > > >
> > > > >
> > > > > if ($_ =~ ( /TEMP/ ))
> > > > >
> > > > >                             {
> > > > >
> > > > >                             my $time = (substr($_, 30, 14));
> > > > >                             $time =~ s/\s//g;
> > > > >                             my $temp = (substr($_, 53, 10));
> > > > >                             $temp =~ s/\s//g;
> > > > >                             $time = ($time * 2.0);
> > > > >                             $time = ?????????????????#convert to
> > > >floatpoint
> > > > >                             foreach ($time)
> > > > >                               {
> > > > >                             print OUT $time ;
> > > > >                             print OUT "    ";
> > > > >                                     foreach ($temp) {
> > > > >                                        print OUT $temp;
> > > > >                                        print OUT "\n";
> > > > >                                                     }
> > > > >                               }
> > > > >
> > > > >                             }
> > > > >
> > > > >
> > > > > cheerio
> > > > > vineet
> > > > >
> > > > > _________________________________________________________________
> > > > > FREE pop-up blocking with the new MSN Toolbar - get it now!
> > > > > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
> > > > >
> > > > >
> > > > >
> > >
> > > _________________________________________________________________
> > > FREE pop-up blocking with the new MSN Toolbar - get it now!
> > > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> > >
> > >
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
> > >
> > >
> > >
> 
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search!
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> 
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to