For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2006 > trouble returning only non-matches









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 trouble returning only non-matches
thesocrat

2006-02-20, 4:17 pm

I tried typing in the entire program, but I kept getting a server error every time I tried to post. Here's the shorter version of my problem:

I have two text files exported (tab delimited) from two Access databases. Each text file contains the same type of data in the respective columns (three columns each), but some of the actual data differs between the two files. I'm trying to write a script that compares the two files and returns only the non-matching records, as well as some reference as to which text file it came from.

I've been trying to use the following argument after telling perl to split the data by tabs:

if ($fileone[0] !~ $filetwo[0] {
print "@fileone\tone"; }

What I'm getting back is every record from the first file printed about 1000 times (the approximate number of total records in the database). I'm guessing this is because it's comparing the first row with each row from the other file, and returning the comparison data for each row from the second file that didn't match. I only want it to return the item from the first file if it doesn't match any of the rows from the second file. I have no idea how to fix this though... can anyone help me out?

Also, I'd like to to return the non-matching data even if column [0] is a match, but column [1] or [2] do not. If you get me past the first obstacle, though, I can probably figure it out from there. Thanks in advance.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com