Re: I don't know where to start with this one.
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Mon, 29 Jan 2007 18:03:12 -0800
Kenton Brede wrote:
I need some advice as to how to approach this problem.
I've got a mail alias file, space delimited and sorted on the second
column like:
a_james@xxxxxxxxxxx ajames@xxxxxxxxxxxxxxxx
david_williams@xxxxxxxxxxx dwilliams@xxxxxxxxxxxxxxxx
j_smith@xxxxxxxxxxx jsmith@xxxxxxxxxxxxxxxx
joe_smith@xxxxxxxxxxx jsmith@xxxxxxxxxxxxxxxx
zach_taylor@xxxxxxxxxxx ztaylor@xxxxxxxxxxxxxxxx
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. 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.
The email would read something like:
----------------------------------------------------------------------------------------------------------------------
These are your email aliases: j_smith@xxxxxxxxxxx, joe_smith@xxxxxxxxxxx
This is your official email address: jsmith@xxxxxxxxxxxxxxxx
----------------------------------------------------------------------------------------------------------------------
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?
Maybe another way to state this is how do I get the lines with
jsmith@xxxxxxxxxxxxxxxx into an array, process that, and then grab a
line with a single address like ztaylor@xxxxxxxxxxxxxxxx and process
that?
Thanks for any pointers. I'd include some code but I don't even know
where to start.
Something like this should work (UNTESTED):
my $mail_alias_file = 'mail alias file';
open my $fh, '<', $mail_alias_file or die "Cannot open '$mail_alias_file' $!";
my %emails;
while ( <$fh> ) {
my ( $alias, $email ) = split or next;
push @{ $emails{ $email } }, $alias;
}
for my $email ( keys %emails ) {
local $" = ', ';
print <<TEXT;
These are your email aliases: @{$emails{$email}}
This is your official email address: $email
TEXT
}
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.
- Follow-Ups:
- Re: I don't know where to start with this one.
- From: Kenton Brede
- Re: I don't know where to start with this one.
- References:
- I don't know where to start with this one.
- From: "Kenton Brede"
- I don't know where to start with this one.
- Prev by Date: Re: Free to wrong pool..
- Next by Date: Re: I don't know where to start with this one.
- Previous by thread: I don't know where to start with this one.
- Next by thread: Re: I don't know where to start with this one.
- Index(es):
Relevant Pages
|