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.
The hash example (was actually in the cookbook) looks like this:
# my @duplicate = ();
# foreach (keys %FILEB) {
# push (@duplicate, $_) if exists $FILEA{$_};
Will the above hash accomplish what I am trying to do.
Hope I haven't muddied the water with my explanation.
Many thanks for the help,
Regards,
Mike Stussie
> -----Original Message-----
> From: King, Jason [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, May 01, 2001 6:39 PM
> To: [EMAIL PROTECTED]
> Subject: RE: finding common records between two files
>
> Mike Stussie writes ..
>
> >I'm a newbie to perl and trying to solve a problem.. Here is what I'm
> >trying to do:
> >
> >read thru flat file 'A' that looks something like this:(fields
> >delimited by
> >'::')
> >BCSNDTJN::Joe User::1 N.
> >Main::Anytown::MO::None::None::None::Unknown::[EMAIL PROTECTED]
> >
> >and find any duplicates based on the email address that might be in
> >flat file 'B'. I want to take the duplicates and output it to another
> >file so that I can administer it later.
> >
> >I found something in the camel book relating to hashes that might do
> >the trick but how do I get the flat file into a hash.
>
>
> excuse me if I've misunderstood - but you seem to be having fun working
> through things yourself and seem to be just looking for a solution to the
> "how do I read a file into a hash" question .. rather than a solution to
> the
> whole thing
>
> so I'll just provide that - in case solving it all will be wrecking your
> fun
> (let me know if I've guessed wrong .. because it's a very simple program
> to
> show you)
>
> also .. your description is unclear .. but I'm assuming that flat file 'B'
> contains just email addresses .. eg.
>
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> so .. here's the trick .. you use the map function to create a new list
> where the lines from 'B' are the keys and you just give them a true value
> (we're using 1 here)
>
> open IN, 'B' or die "Bad open: $!";
> my %check = map { chomp; $_ => 1 } <IN>;
>
> so .. if the above example email addresses were in 'B' then now you'd have
> the following hash
>
> $check = ( '[EMAIL PROTECTED]' => 1,
> '[EMAIL PROTECTED]' => 1,
> '[EMAIL PROTECTED]' => 1
> );
>
> so hopefully your camel example will now enable you to look through 'A'
> checking whether the email address is a duplicate
>
> --
> jason king
>
> In New York, a fine of $25 can be levied for flirting. This old law
> specifically prohibits men from turning around on any city street and
> looking "at a woman in that way." A second conviction for a crime of
> this magnitude calls for the violating male to be forced to wear a
> "pair of horse-blinders" wherever and whenever he goes outside for a
> stroll. - 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.
***************************************************************************************