On 1/29/07, Kenton Brede <[EMAIL PROTECTED]> wrote:

I've got a mail alias file, space delimited and sorted on the second
column like:

That's handy that it's space delimited; you won't be needing anything
fancy to extract the addresses.

[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]

I need to send an email to each of the addresses on the right.  I
could send this line by line but then jsmith would get two emails,
when I want to send one.

That sounds as if you want to build a hash whose keys are the unique
addresses from the second column.

The second thing I need to do is grab all
these addresses to use as variables in the body of the email that will
get sent.

So the values stored in that hash need to (somehow) give you the
addresses from the first column. In one way to do it, each value would
be a reference to an array of first-column addresses. Another way, the
value would be a string with a newline after each address. Perl makes
it easy to build either hash:

   push @{ $hash{$key} }, $new_address;  # by reference

   $hash{$key} .= "$new_address\n";  # newline delimited

The part I need help with is how to grab lines in the file with the
same email address (address on the right) and treat them as "one
record" as well as treat those with a single email address as one
record?

If you've gotten this far with the hash idea, I think you're now
wishing to see whether an entry in the hash has more than one address,
and whether the address in the key is among the addresses. Is that it?
Those should be straightforward tasks, but post again if you're still
stuck.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to