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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Matching an Id to a Database



Jan 25, 2001, 1:35 PM

Post #1 of 3 (191 views)
Matching an Id to a Database Can't Post

Alright I've run into a problem. This probably should be Beginner, but whatever. This is what I'm trying to do. First my script will open up a database that contains this:

1``Forum One``1 
2``Forum Two``1

Where I'm targeting the final 1 as the user id. Then I open up another database containing this:


I want to match the 1 at the end of the first database to the user in the secound database. This is the code I have so far:

for ($x = 0; $x < @forums; $x++) { 
($id[$x], $name[$x], $mod[$x]) = split(/``/, $forums[$x]);
for ($y = 0; $y < @users; $y++) {
($uid[$y], $uname[$y]) = split(/``/, $users[$y]);
if ($uid[$y] eq $mod[$x]) { $mod[$x] = $uname[$y]; }

Where @forums is the first database, and @users was the secound database. There is a bug in the code. It will match up the user for the secound forum in the first database, but not for the first. See the results at:

Anybody ever have this problem and have a solution?



Jan 25, 2001, 2:21 PM

Post #2 of 3 (187 views)
Re: Matching an Id to a Database [In reply to] Can't Post

The inner split is only catching two variables, when in fact there are 3 in the array. I don't know where the third field goes. Perhaps it evapourates or perhaps it's appended to the second receiver ($uname[$y]).

You can get around this by writing

($uid[$y], $uname[$y]) = split(/``/, $users[$y])[0,1];

The other posibility is that the datafiles themselves have been corrupted, so that when you think you have 3 values separated by '', you could have anything.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


Jan 25, 2001, 3:46 PM

Post #3 of 3 (182 views)
Re: Matching an Id to a Database [In reply to] Can't Post

That just produced an error. Anyways, I dont think you understand what I'm trying to do. The forumslist database has the 1 as an indicator of the user that matches it. So it opens the user database and finds the user with the id number 1. Then replaces the variable that contains the number from the forumslist with the corresponding name found in the user database.


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

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