Re: Little script help please
On Thu, Sep 07, 2000 at 05:57:32PM -0600, Art Sackett wrote:
> On Fri, Sep 08, 2000 at 09:36:51AM +1000, ridgey wrote:
> > Below is a script I am writing, what it does it take in values from
> > webpage and basically just write them to a file.
> First thing to do is to stop writing perl like it's sh. Second thing
> would be to ditch cgi-lib.pl in favor of CGI.pm.
> I don't wish to offend, but don't really know what else to say. I
> don't even see why the thing you wrote does anything at all... seems
> like it should bark and die straight away. It surely would if you had
> warnings enabled.
a third thing to do would be to use a real database server, or at least an
sql backend of some kind.
if you don't want to install postgresql or mysql, then consider using
the DBD::CSV perl module - gives you all of the features of perl DBI (at
least, all those which make sense with a flat text file), but working
with flat text files instead of a db server.
what this means is that you can search, insert, update and delete
records without stuffing around - issue the appropriate SQL command
and it just works....and you don't have to worry about file/record
locking, or locating the correct place in the file to insert a record or
anything. the DBD module does all that for you.
alternatively, use the DBI Xbase module - works in the same way as any
other DBI/DBD module but using xbase (aka dbase, foxbase, etc) files on
the local disk. advantage is that the xbase supports typed fields (e.g.
int, string, date) whereas in DBD::CSV, all fields are essentially text
fields. it's also much faster than DBD::CSV (although that's not a huge
issue if your data file is small)
in short: don't reinvent the wheel, there are perfectly good wheels