Jason... thanks for responding... let me clear up a couple of things and
perhaps you can provide further guidance.

The email broke the record into 2 lines, each record is actually only one
line  of which the only field that concerns me is the email address. Here
are the record examples again (shortened for demo purposes)

FILE' 'A' - 
PLWP4::Joe User::1 Main St::Anytown::MO::[EMAIL PROTECTED] 


FILE' B' - 
XY3G4::Susie User::1 Main St::Anytown::MO::[EMAIL PROTECTED] 


The purpose is to add file 'B' to file 'A'  but if the email address from
file 'B' already exists in file 'A' do not add it but print out the record
containing the duplicate email address. 

Thank you for any further guidance that can be provided.

Regards,
Mike Stussie

> -----Original Message-----
> From: King, Jason [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, May 02, 2001 8:00 PM
> To:   [EMAIL PROTECTED]
> Subject:      RE: finding common records between two files
> 
> Mike Stussie writes ..
> 
> >thanks for the response... let me clarify the description of 
> >file 'B'....
> >
> >File 'B' record format is exactly like file 'A', both look like this:
> >(btw - the file is a registrant file for a newsletter)
> >
> >File 'A'
> >BCSJN::Joe User::1 
> >N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> >
> >
> >File 'B'
> >JKQWZ::Susie Queue::1 
> >N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> >
> >
> >The purpose is to add file 'B' to file 'A' (the master file) and then
> >send out an email to all registrants which are now contained in file
> >'A', but I don't want to send out duplicate registrations, hence the
> >need to check for duplicates via the email address.
> 
> 
> ok .. well - listen to what you actually want to do .. you want to read
> everything in from 'B' that is NOT in 'A' (you had it the other way around
> before)
> 
> so the first step is to build the hash from 'A' .. because that's the one
> that you're going to check the entries in 'B' against
> 
> and you'll want to do something a little tricky because from the look of
> the
> data your records are spread over two lines .. so you'll want to do
> something like this
> 
>   open A_FILE, 'A' or die "Bad open: $!";
> 
>   my %check;
>   while(<A_FILE>)
>   {
>     $_ = <A_FILE> or die "Uneven record: $.";
>     chomp;
> 
>     my $address = (split /::/)[-1];
> 
>     $check{$address} = 1;
>   }
> 
> 
> then you'll open 'A' for appending .. and 'B' for reading .. and read
> through B grabbing records and appending them to 'A' unless they're in
> your
> hash
> 
>   open B_FILE, 'B' or die "Bad open: $!";
>   open A_FILE, '>>A' or die "Bad open: $!";
> 
>   while(<B_FILE>)
>   {
>     my $next = <B_FILE> or die "Uneven record: $.";
>     my $address = (split /::|\n/, $next)[-1];
> 
>     print A_FILE $_, $next unless exists $check{$address};
>   }
> 
>   close A_FILE or die "Bad close: $!";
> 
>   __END__
> 
> note the ugly double read that we're doing .. that's because from your
> email
> I'm guessing (because you never really said) that your data looks
> something
> like this
> 
>   BCSJN::Bill User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
>   BCSJN::Joe User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
>   BCSJN::Paul User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> 
> ie. with one record after another with no record separator .. if it's
> actually like this
> 
>   BCSJN::Bill User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> 
>   BCSJN::Joe User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> 
>   BCSJN::Paul User::1 
>   N.Main::Anytown::MO::None::Unknown::[EMAIL PROTECTED]  
> 
> 
> then the problem is much simpler .. see the $/ variable in the perlvar
> documentation (type the following at the command prompt)
> 
>   perldoc perlvar
> 
> you might not be familiar with the split() function above
> 
>   perldoc -f split
> 
> -- 
>   jason king
> 
>   In Norway, you may not spay your female dog or cat.  However, you may
>   neuter the males of the species. - http://dumblaws.com/


***************************************************************************************
WARNING:  All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.
***************************************************************************************

Reply via email to