in reply to How to do script to separate name and email domain ?
I just split the email addresses by the @ symbol, then pushed each user into an array that is keyed to the domain. After that I counted the values of each array in the hash and printed the results.
#!/usr/bin/perl use strict; use warnings; my %email_domains; for my $email_address (@email_list) { my ($before_at, $after_at) = split('@',$email_address); push @{$email_domains{$after_at}}, $before_at; } for my $domain (sort keys %email_domains) { my $count = @{$email_domains{$domain}}; print "$domain: $count"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to do script to separate name and email domain ?
by dasgar (Priest) on Sep 07, 2010 at 05:29 UTC |