Home > Archive > PERL Miscellaneous > March 2004 > Re: Help: Deleting Entries in Flat File Database
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Help: Deleting Entries in Flat File Database
|
|
| James Willmore 2004-03-19, 1:23 pm |
| On Thu, 18 Mar 2004 16:37:54 -0500, TP wrote:
> Hi all, i am a newbie in Perl and have been playing around with FFD,
FFD ... no, I don't think that's a real term - at least in the context you
meant :-)
[ ... ]
Just a suggestion ... you may want to think about using the DBI module and
the DBD::CSV (or DBD::SQLite) module to interact with your file.
You could then use SQL statements instead of going through the exercise of
parsing the file by hand. As an added benefit, you won't need to alter
the code that much if you decide latter to use a "real" database :-)
Again, just a suggestion.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Famous, adj.: Conspicuously miserable. -- Ambrose Bierce
| |
| Joe Smith 2004-03-28, 10:22 pm |
| TP wrote:
> Hi all, i am a newbie in Perl and have been playing around with FFD,
> and i have succefully scripts for add, read and search for my database. I
> have some problem writing the scripts for deleting entries from my database.
....
> #check for match
> foreach $line (@array){
> if($line=~ /$del1/){
> $continue++;
> }
.... convoluted code snipped ...
@newarray = grep !/$del1/, @array;
exit if $#newarray == $#array; # Nothing to do if no changes
> # Rewrite the file
> open(DB,">>$dbpath");
> while(($key,$value)=each(%movies)){
> print DB"$value\n";
Rewrite is ">" not ">>".
-Joe
| |
| Uri Guttman 2004-03-28, 10:22 pm |
| >>>>> "JS" == Joe Smith <Joe.Smith@inwap.com> writes:
JS> ... convoluted code snipped ...
JS> @newarray = grep !/$del1/, @array;
JS> exit if $#newarray == $#array; # Nothing to do if no changes
exit if @newarray == @array; # Nothing to do if no changes
i prefer @foo for that. i stay away from $#foo unless it is really
needed. it is just too fugly and i feel misleading to too many. i hate
to see it used when not needed as well like in if $#foo > -1 instead of
if @foo.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
|
|
|
|
|