Displaying exponent value as string in PERL script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying exponent value as string in PERL script
# 1  
Old 10-06-2011
Displaying exponent value as string in PERL script

Hello All,

I am currently having an issue displaying a exponent value using perl,

I have a perl program which generates an xls file. This xls is populated with values from a database. But for a certain column which I have made explicitely text and also implemented keep_leading_zeroes() property , I find that when I have a DB value like “16951E194″ the xls populates it as 1.6951e+194 . How do I resolve this with perl.

Thanks in advance
S
# 2  
Old 10-06-2011
If its the Spreadsheet::WriteExcel which is generating the xls files.
you can force the values to be "string" with write_string method.
Probably you are using the write method which automatically resolves the datatype and set the property accordingly.

Code:
$worksheet->write_string(.......)

# 3  
Old 10-06-2011
Thanks Anchal. I am using write_row() after getting the row from the database . In the complete worksheet I have several columns which I need as integers. Is there a way I can make particular column in the xls as text . This is what I am using now

my $format = $workbook->add_format(num_format => '@');
$sheet1->set_column('D:G', undef, $format);
$sheet1->keep_leading_zeros();

The value in the above columns are comming as left intended but I have the exponential issue mentioned earlier

Any workaround for that ?
This User Gave Thanks to reshkraj For This Post:
# 4  
Old 10-06-2011
I suspect it's not Perl that's doing this, it's Excel. Import from CSV and you'd have the same problem. People often have problems with Excel mangling anything that looks even slightly date-like, too.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Displaying a number in binary using perl

printf FH2" 3'b%b : begin\n",$i; where i is an integer in the loop is displaying 3'b1 : begin expected output was 3'b001 : begin (1 Reply)
Discussion started by: dll_fpga
1 Replies

2. Shell Programming and Scripting

Perl script - Help me extracting a string

I have input like this : TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-FEB-2012 04:19:45 Copyright (c) 1997, 2009, Oracle. All rights reserved. Used parameter files: /t3local_apps/apps/oracle/product/11.2.0/network/admin/sqlnet.ora Used TNSNAMES adapter to resolve... (3 Replies)
Discussion started by: dnam9917
3 Replies

3. Shell Programming and Scripting

Perl: Comparing to two files and displaying the differences

Hi, I'm new to perl and i have to write a perl script that will compare to log/txt files and display the differences. Unfortunately I'm not allowed to use any complied binaries or applications like diff or comm. So far i've across a code like this: use strict; use warnings; my $list1;... (2 Replies)
Discussion started by: dont_be_hasty
2 Replies

4. Shell Programming and Scripting

Finding a string and displaying the text before?

Hi folks. I am trying to script a query of a backup server that will display sessions that are "waiting" for a mount... So for, i query my system which returns a process # that is waiting... The output looks like this: 20,984 Backup Storage Pool Primary Pool T950_TAPE_WIN, Copy Pool... (3 Replies)
Discussion started by: Stephan
3 Replies

5. Shell Programming and Scripting

Script to raise a integer by a exponent (while loop)

I am trying to write a script that raises a integer (m) by a exponent (n) using a while loop ex. 5 raised to the power of 2 .. I am a beginner and i dont know what is the opperand or command i have to use to make this happen..this is what i have so far... echo "Enter a integer for the... (3 Replies)
Discussion started by: jibz
3 Replies

6. Shell Programming and Scripting

PERL- converting exponent value to floating point

Hi Friends, I've an exponent value like, $val="9.57669e-05"; I want to convert this value to floating point value in PERL scripting. I tried googling for the solution, and also asked many perl friends. Unfortunately, I didn't get answer. Could you please help me? Thanks in advance... (4 Replies)
Discussion started by: ganapati
4 Replies

7. Shell Programming and Scripting

Displaying only First Occurrence of a String

Hi, My requirement is that I should search for a particular string and display the string only once if there is more occurrence of the same string in a file. e.g In the given below log file,the string AMQ5037 comes twice.I want to search for this string and display it only once.grep will... (5 Replies)
Discussion started by: charudpss
5 Replies

8. Shell Programming and Scripting

Displaying text file in browser - perl

Don't know why this didn't get posted before but... I am having issues displaying a log file in the browser using perl and I can't get it to display at all, All i get is WHITE (blank page). I have proper permissions in my cgi-bin directory and everywhere else. So I know that's NOT the issue. ... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

9. Shell Programming and Scripting

Displaying text file in browser - perl

I am having issue dispalying text file in browser using perl. Here is my code: #!/usr/bin/perl print "content-type: text/html \n\n"; open (FH , "access.log") || die "Blah $!"; while (<FH>) { print $_ ; } I have correct permissions and everything. The weired thing is when I... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

10. Shell Programming and Scripting

Displaying double quotes using Perl

Hi Guys, I'm a Perl newbie and was wondering if there's a way of displaying double quotes within double quotes. I'm try to print the contents of the variable to a file by using the system function. Here is an example of my code: #============================== $website = <STDIN>;... (2 Replies)
Discussion started by: kbdesouza
2 Replies
Login or Register to Ask a Question