First, use CGI.pm to parse the data from the get and post.

Second, understand that you are not dealing with a database, but a flat file. Big difference. If you are stuck with a flat file, sobeit but it is not a database.

Try opening the file for read, put it into an array, loop through this array, push each record onto a new array unless a match is found and then print the contents of the second array into the file:

#!/usr/bin/perl -Tw use CGI qw(:standard); use strict; # delete a specific line if (param('action') eq 'delete' { open(FILE,"$file"); while(<FILE>) { chomp; ($company_name,$street,$city_st_zip,$phone,$fax,$website,$email,$c +ategory,$storefront,$logo,$alpha,$first_name)=split(/\|/); if (param($company_name) eq $company_name || ....) # match { push(@file,$_); } } close(FILE); open(FILE,>$file); { foreach (@file) { print FILE $_ . "\n"; } } }

I am not totally sure this will solve your problem but it will make your code easier to read and therefore easier to debug.


I admit it, I am Paco.

In reply to Re: Wierd DB Question by jonjacobmoon
in thread Wierd DB Question by lisaw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.