473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Getting input from STDIN

9
I have used use Spreadsheet::WriteExcel::FromDB::Query package to retrieve the values from database to Excel sheet using the following program.

Expand|Select|Wrap|Line Numbers
  1. use Spreadsheet::WriteExcel::FromDB::Query;
  2. my $dbh=DBI->connect("DBI:mysql:tito:localhost","","");
  3.  
  4. $query=q{SELECT Engg_ID from mastertable where Project_ID='8'};
  5.  
  6. $ss->write_xls('spreadsheet112.xls');
  7.  
The above program is working fine. But if i want to give the value for Project_ID through command prompt it is not updated properly in Excel sheet.

Expand|Select|Wrap|Line Numbers
  1. print "Enter the project ID";
  2. $s = <STDIN>;
  3.  
And used the query:
Expand|Select|Wrap|Line Numbers
  1. $query = q{SELECT Engg_ID from mastertable where Project_ID='$s'};
  2.  
Can anyone help me out in debugging the above program.

Thank You
Feb 26 '07 #1
1 6114
miller
1,089 Expert 1GB
Most likely you just need to chomp the $s variable to remove any return character from your inputted data.

Expand|Select|Wrap|Line Numbers
  1. print "Enter the project ID";
  2. my $s = <STDIN>;
  3. chomp $s;
  4.  
If people other than yourself are going to be using this, then I would suggest that you do some other data validation as well. Verifying that it is only an integer for example would prevent simple errors and potential malicious input.

Expand|Select|Wrap|Line Numbers
  1. $s =~ s/.*?(\d+).*/$1/;
  2.  
- M
Feb 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris John Jordan | last post by:
How can one get a text control's size to fill the available space e.g. the width of the cell? I find not input type=text size=100% .. Thanks. -- Chris
11
by: Ray Muforosky | last post by:
I have this: ------------ print "<FORM name=\"form3\" ACTION=\"cmdlog_rep.php\">\n"; print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\"></TD>\n"; .. print "<INPUT type=\"HIDDEN\"...
8
by: Spartan815 | last post by:
is there another function or way of going about getting input from the command line besides getch(). Right now, Im just doing a simple while loop (terminated by a new line character) to get input,...
4
by: Johnathan Doe | last post by:
I'm trying to find a way to reliably peek at stdin, and if anything's waiting, flush stdin so that it clears the stream ready to wait for a character. The problem I have is that in an...
3
by: Fao, Sean | last post by:
Hello all, As stated in another message, it's been a long time since I've done any C coding and I'm not feeling comfortable that I'm doing this correctly. Basically, I'd like to verify that my...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
3
by: doughboy | last post by:
I have just started learning perl. I have to write a script that will ask a persons info, ask if you want to add more records, and once it is done print all the info with a : between the fields and a...
4
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs,...
9
by: xlsmnt | last post by:
I've recently started working with C++ and wondered if there was a "right" way for getting input from the console window. From what I've seen whenever I attempted to implement it more than once,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.