Chris Charley wrote
The solution above *assumes* that you would know beforehand the widths you
want for each column (determined by the largest number in each column you
want to format).
The solution below allows you to determine the greatest width required
programmatically using the max() fun
[...]
Hi Vineet
You could format *pretty* by using sprintf() instead of print. I would do
it like below.
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 (){
if (/TEMP
Vineet Pande wrote:
Thanks Rex:
Please help me in knowing one more related thing. I have from this script
of mine an output like this:
0.00.00
0.460.37
0.8106.29
1.2140.56
1.6168.75
2.0186.37
2.4207.82
2.8225.45
3.2235.88
3.6245.55
4.0250.61
4.42
cted 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. "Deci
CTED]>
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
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 i
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));