K
Koncept
Sorry for asking, but I give up on this situation. I am a total n00b at
Perl and have only used it seriously for about 1 week now. I would
really appreciate somebody's help here because I am really feeling
stuck.
** THIS IS NOT A SPAM LIST FIRST AND FOREMOST **
I have a list of email accounts. Many of the email accounts have are
from the same domain.
I want to seperate this huge list into seperate lists, where each list
only contains one address from each domain.
Example:
If my addresses in the source file are as follows:
bill at one.com
jane at one.com
frank at two.com
ted at one.com
jess at three.com
My first run should return:
--------------------
bill at one.com
frank at two.com
jess at three.com
2nd run:
------
jane at one.com
3rd run:
------
ted at one.com
I came up with this to grep unique domains once, but the problem is
that the script only runs once.
#!/usr/bin/perl -w
sub div() { "+","-" x 50, "+\n"; }
die "Usage: $0 emailList" if (@ARGV!=1);
open( EML, $ARGV[0] ) || die "Can't open file : $!\n";
while(<EML>){
chomp;
push(@addys, $_) if $_ =~
/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
}
close( EML );
foreach $email( @addys ) {
@parts = split( "@", $email );
$domain = $parts[1];
unless( $seen{$domain} ) {
push( @users, $email );
$seen{$domain} = 1;
}
}
if(@users>0){
print &div, "The following are uniq users per domain:\n", ÷
print join( "\n", sort( @users ) ), "\n", ÷
} else {
print "Sorry. I could not find any email addresses.\n";
}
Perl and have only used it seriously for about 1 week now. I would
really appreciate somebody's help here because I am really feeling
stuck.
** THIS IS NOT A SPAM LIST FIRST AND FOREMOST **
I have a list of email accounts. Many of the email accounts have are
from the same domain.
I want to seperate this huge list into seperate lists, where each list
only contains one address from each domain.
Example:
If my addresses in the source file are as follows:
bill at one.com
jane at one.com
frank at two.com
ted at one.com
jess at three.com
My first run should return:
--------------------
bill at one.com
frank at two.com
jess at three.com
2nd run:
------
jane at one.com
3rd run:
------
ted at one.com
I came up with this to grep unique domains once, but the problem is
that the script only runs once.
#!/usr/bin/perl -w
sub div() { "+","-" x 50, "+\n"; }
die "Usage: $0 emailList" if (@ARGV!=1);
open( EML, $ARGV[0] ) || die "Can't open file : $!\n";
while(<EML>){
chomp;
push(@addys, $_) if $_ =~
/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
}
close( EML );
foreach $email( @addys ) {
@parts = split( "@", $email );
$domain = $parts[1];
unless( $seen{$domain} ) {
push( @users, $email );
$seen{$domain} = 1;
}
}
if(@users>0){
print &div, "The following are uniq users per domain:\n", ÷
print join( "\n", sort( @users ) ), "\n", ÷
} else {
print "Sorry. I could not find any email addresses.\n";
}