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/

Reply via email to