--- bc <[EMAIL PROTECTED]> wrote:
> i'm an old asp/vbscript dude, i do not know how to "...make sure the
> file is open" either? any real quick explanation you can give me to
> get the file open in perlScript/CGI? to match what you said below?
lol ok:
use strict; # option explicit, but better =o)
use warnings;
use diagnostics -verbose; enable diagnostics;
use CGI;
print CGI->header, CGI->start_html, "<table border=1>\n";
# you might also want some column headers here.
# I don't know the filename, so edit this:
open CSV, "your.csv" or die $!;
# inserting from below:
while(<CSV>) { # read a line
s/^/<TR><TD>/; # start the table row and first cell
s{,}{</TD><TD>}g; # seperate fields into cells
s{$}</TD></TR>}; # close the last cell and the row
print "$_\n"; # I like to add the newline
}
close CSV;
# then end:
print "</table>",CGI->end_html;
exit;
You may need to clean it up a bit. =o)
> > --- bc <[EMAIL PROTECTED]> wrote:
> > > how, in perl/cgi, or, what is a popular way of connecting to, and
> > > displaying, a csv file's contents to a browser, in table form?
> >
> > Er.
> >
> > Okay, um....
> > CSV as in Comma Seperated Values?
> > ...start the page, print the table headers, make sure the file is
> open,
> > then
> >
> > while(<CSV>) { # read a line
> > s/^/<TR><TD>/; # start the table row and first cell
> > s{,}{</TD><TD>}g; # seperate fields into cells
> > s{$}</TD></TR>}; # close the last cell and the row
> > print "$_\n"; # I like to add the newline
> > }
> >
> > then print the table closing lines, etc.
> >
> > That's kinda clumsy, but doesn't require anything too fancy.
> > You could also do a split/join if you prefer, but you'd still have
> to
> > handle the start and end of each line.
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute with Yahoo!
> Messenger
> > http://phonecard.yahoo.com/
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]