Perl isn't a strong type language,it doesn't mind which data type it used.
> You can use printf() for printing a floating vlaue,like,
> $ perl -e 'printf("%.2f",3)'
> 3.00


that's right, but with respect to this particular code of mine, the $cdr[13]
is the "amount" field which should be a float.  I am manipulating it like
this:-

 while ($line=readline($IN_FILE))
            {
                my @cdr=split (/,/, $line) ;
                $cdr[13] = $cdr[6]*5.0 ;
                $line = join(",",@cdr);
                $hash{"@cdr[2,3,6,7]"}=$line;
            }

and then writing the output like this:-

open (my $OUT_FILE,">","$write_path/$file.out") or die $!;
            while (my($key, $value) = each %hash)
            {
                print $OUT_FILE $value;
            }

Here if I want the $cdr[13] to be written as a float(ex. 15.00), then how do
I write it?

Thanks,
Mihir

Reply via email to