Syntactic Confectionery Delight | |
PerlMonks |
(dkubb) Re: (2) Using Files w/DBD::CSVby dkubb (Deacon) |
on Mar 05, 2001 at 01:26 UTC ( [id://62131]=note: print w/replies, xml ) | Need Help?? |
Here's an example showing what you want to do with DBD::CSV:
Note: The above code assumes that your file name is "list". DBD::CSV can only process files without any extension. Also, if this is going into production you might want turn on Taint checking by appending a T to the first line, as well as validating each of the CGI paramters, possibly using HTML::FormValidator, which is my personal favorite for this. The great thing about using DBD::CSV is that if you ever switch to using a relational database all the code won't need to change, assuming your schema stays the same. This is why I explicitly define the environment variable $ENV{DBI_DSN} at the top of the script, so that you can easily change it later. Keep in mind this varible globally defines the data source that all the DBI->connect method calls will use, and can be globally set for all your CGI's in Apache's httpd.conf. As well, I do suggest you look into relational databases, like MySQL or PostgreSQL. They might be better suited for storing this type of information than a flat file.
In Section
Seekers of Perl Wisdom
|
|