By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,851 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,851 IT Pros & Developers. It's quick & easy.

print .csv table in browser in perl -cgi

P: 1
this code print file in browser but in in tabular form like in .csv file.....kindly help me out....

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. # use lib
  3. use strict;
  4. use CGI;
  5.  
  6. # limit 1000K bytes post, permit upload
  7. $CGI::POST_MAX        = 1024 * 1000;
  8. $CGI::DISABLE_UPLOADS = 0;
  9.  
  10. my $cgi   = new CGI;
  11. my $title = "Perl Upload";
  12.  
  13. up {
  14.  
  15.         if (!$cgi->param()) {
  16.  
  17.       print $cgi->header();
  18.        print "<html><title>hh</title>";
  19.  
  20.   print "<body><form method='post'enctype='multipart/form-data'>
  21.         <input type='file' name ='filename' size='30'>
  22.         <input type='submit' name'.submit value='upload'>
  23.         <input type ='reset' name =.reset' value ='clear'></form>
  24.         </body></html>";
  25.  
  26.  
  27.  
  28. } else {
  29.  
  30.  
  31.   my $file = $cgi->param("filename");
  32.   my @filedata = <$file>;
  33.  
  34.     foreach (@filedata) {
  35.     s/</&lt;/g;
  36.     s/>/&gt;/g;
  37.  
  38.  
  39.  
  40.    }
  41.  
  42.  
  43.          print $cgi->header();
  44.          print"<html><title></title>";
  45.          print "<body>";
  46.         foreach (@filedata) {
  47.  
  48.                 print "<table border='1'><tr><td>$_<br></td></tr></table>";
  49.         }
  50.         print "</body></html> \n\n";
  51.  
  52.      wrt{
  53.         open (FH,">>$file");
  54.         print FH @filedata;
  55.         print "....................uploaded";
  56.         }
  57. }
  58. up();
  59. }
Apr 21 '08 #1
Share this Question
Share on Google+
2 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
First, can we see a sample line of the data so we can better know what we are dealing with? Second, what are you planning on using for the keys of the hash?

Unfortunately, I don't see a question other than "can you help me out?". What is the problem you are having with your code? What are you seeing / not seeing? What are you expecting your code to do? Can you provide sample data for us to work with?

Regards,

Jeff
Apr 24 '08 #2

eWish
Expert 100+
P: 971
Please do not double post your questions. I have deleted your other thread regarding the same issue and same code.

--Kevin
Apr 25 '08 #3

Post your reply

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