Re: converting to FLOATING_POINT..



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 <pande_vineet@xxxxxxxxxxx> 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: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
.



Relevant Pages

  • Re: Parse and Compare Text Files
    ... I've found this script on another message board that is close, ... >> Categorized Domains List ... > perldoc -f print ... > store categorized domains into an easily accessible data structure ...
    (perl.beginners)
  • Re: Critcize my scripts.
    ... > (I know it's a good practice to put use strict in Perl ... > use strict.The script below work fine if I comment out ... perldoc -f use ... Sub Routines ...
    (perl.beginners)
  • Re: the code for bbs 3
    ... perldoc constant ... Consider using a template module which lets you separate output from Perl ... You are constantly referring to $PARAMSthroughout the script. ... Learn how to program, _then_ start programming. ...
    (comp.lang.perl.misc)
  • Re: qx and awk for array
    ... >> Having trouble with this command when placed in a perl script: ... I enabled warnings(use warnings;) on the script and got no warning ... > perldoc -q quoting ...
    (comp.lang.perl.misc)
  • Re: Translate VBScript Which gets Computer Names to Perl
    ... If the script works in VBScript, why are you trying to translate it? ... Perl, I would use VBscript. ... perldoc -f push ...
    (microsoft.public.scripting.vbscript)