CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Database Question

 



enhost
Deleted

Jan 23, 2000, 5:39 AM

Post #1 of 5 (2671 views)
Database Question Can't Post

Ok.. I have a program that writes a flatfile database using : as a delemiter.

Now I have a form where a user types in all their info.. if they have a checking account it writes it into a sepearate database.

Now what I need to do is have a HTML form were a user can type in their checking account information AGAIN and compare it with whats is in the database. If what they type in does not match EXACTLY then I need it to delete that line out of the database file, basicly I need to create a Check Authorization script. Below is some code I'm using to open the database.. but I don't know how I would compare it.. and if anything don't match exactly how I would go about deleting just that one line out of the database file.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


# Open and Read CheckAuth Database #
open (CKAUTH, "$checkauthlocation");
while (<CKAUTH> ) {
chop;
($bankname, $actnumber, $rtnumber) = split(/:/,$_,3) ;
$bankname{$bankname} = $banknamefinal;
$actnumber{$actnumber} = $account_number;
$rtnumber($rtnumber) = $routing_number;
}
close(CKAUTH);
</pre><HR></BLOCKQUOTE>

If anybody has any ideas or code.. Any help would be appreciated.. thank you.


enhost
Deleted

Jan 23, 2000, 7:25 PM

Post #2 of 5 (2671 views)
Re: Database Question [In reply to] Can't Post

How would you go about deleting a single line out of a file?

I figured out how to compare whats entered with what is in the database file... but if everything checks out ok.. I want to deleted that line out of the database.. anybody know any way of accomplishing this?


Borderline
Deleted

Jan 24, 2000, 5:22 AM

Post #3 of 5 (2671 views)
Re: Database Question [In reply to] Can't Post

Hi,

For deleteing a line from a text file check out one of my earlier posts.

Also on the code you posted. You should be checking the return from the open like this

open CKAUTH, $checkauthlocation or die "Could not open $checkauthlocation: $!";

You would also be better off using chomp than chop in this case.

HTH
Scott


enhost
Deleted

Jan 24, 2000, 8:06 AM

Post #4 of 5 (2671 views)
Re: Database Question [In reply to] Can't Post

lol, Thank you for the or die.. was just trying to figure that out Smile .. but that leads me to another questions.. what is the difference between chop and chomp?


Borderline
Deleted

Jan 24, 2000, 8:22 AM

Post #5 of 5 (2671 views)
Re: Database Question [In reply to] Can't Post

chop take the last element off a string and returns it. chomp will only take off new line characters eg \n
So if for some reason you file does not end with a new line then a character from the data will be lost using chop.
Therefore if all you are doing is taking off the new line character chomp is better and safer.

Scott

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives