Stamp_Guy has asked for the wisdom of the Perl Monks concerning the following question:
my $number = $cgi->param('number'); open(DATABASE, "database.dat") || die "Couldn't open the database for +reading: $!"; @database=<DATABASE>; close(DATABASE); my @data = split(/\|/, $database[$number]); # Do all my manipulations here $database[$number] = join('|', @data); open(DATABASE, ">database.dat") || die "Couldn't open the database for + writing: $!"; foreach (@database) { chomp; print DATABASE "$_\n" if ($_ ne ""); } close(DATABASE);
It seems to me that this is a bit error/bug prone. Is there a better way to do this? There is also the remote possibility that I may get multiple users on this system in which I am sure this system would fail. Could anyone tell me a more secure way to do this?
I'm a self-taught programmer. I have no formal training what-so-ever. Any suggestions as to how I could improve both my system and my code would be greatly appreciated! Thanks!
Stamp_Guy
Computers aren't intelligent, they just think they are.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Flat File Editing Question
by jorg (Friar) on May 24, 2001 at 04:10 UTC | |
|
Re: Flat File Editing Question
by no_slogan (Deacon) on May 24, 2001 at 04:03 UTC | |
|
Re: Flat File Editing Question
by Banky (Acolyte) on May 24, 2001 at 07:24 UTC |