MBolton has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to use the Table.pm and followed the instructions/examples on the CPAN site but I can't seem to get it to work correctly. What I am trying to do is access a .csv file on my server and have its contents displayed in an HTML table. Based on what I read about Table.pm, it seems like it should be the perfect fit. Here's the general snippets that I am using to try and make it work:
use Data:: Table; $t = Data::Table::fromCSV("/cgi-bin/testme.csv"); print $t->html;
From what I understand, it should be about as simple as that to get it to do what I am attempting to do. I've checked my syntax against the syntax in the CPAN examples and I've checked other sites and can't seem to get to the bottom of it. Any help that someone could lend would be great! Thanks!

Replies are listed 'Best First'.
Re: Question about Table.pm
by Tanktalus (Canon) on Feb 25, 2005 at 21:32 UTC

    Works fine for me here - as bibliophile pointed out, the space in your use statement after the :: has to go. Also make sure that /cgi-bin/testme.csv exists. Just because it's "http://your.domain.net/cgi-bin/testme.csv" doesn't mean that it's "/cgi-bin/testme.csv" to perl. In fact, it probably isn't. Even if it were, I'd suggest moving it - you shouldn't put your cgi-bin directory at the root of your filesystem. Put it in /srv/www/cgi-bin or /var/httpd/cgi-bin or even /home/apache/cgi-bin or something. Wherever the file really is on your filesystem, that's what you have to pass in to Data::Table.

      Ahh I think I see something: Looks like /cgi-bin is really a sym link. The real path is /usr/local/apache2/cgi-bin. Let me try putting that whole path in there and see what happens....
        Well, I tried that also and it still didn't work. It just simply does not display the output to the web page at all. One thing I neglected to mention is the fact that the Table.pm module wasn't even installed on this server until this morning when I pestered a teammate of mine to put it on there. Is there something that he may have done incorrectly in the installation? When I look at the Table.pm file, the code contained within looks identical to what I see on CPAN...
Re: Question about Table.pm
by bibliophile (Prior) on Feb 25, 2005 at 21:13 UTC
    At a first guess, that should probably be: print $t->html;
      Oops.. that's what I meant to type.. that's actually how my code is written:
      print $t->html;
      Sorry about that.. I also meant to mention that I have tried using this module against several different valid .csv files and it does not seem to be working as advertised. Of course, it could be user error. LOL
        Hmm. I just tried your code, and (after getting rid of the space in 'Data:: Table'), it worked for me.
        I *was* using a testme.csv in my current directory, though... maybe that's got something to do with it?

        What kind of error messages do you get?