On Mon, Aug 01, 2005 at 06:08:00PM -0400, Noel Maddy wrote:
> On Sun, Jul 31, 2005 at 07:52:42PM -0400, Ryan Anderson wrote:
> > On Sun, Jul 31, 2005 at 02:45:29AM -0700, Junio C Hamano wrote:
> > > Ryan Anderson <[EMAIL PROTECTED]> writes:
> ...
> > > 
> > > Also you seem to be losing the ordering in @to and @cc by the
> > > use of uniquefying "keys %to" and "keys %cc".  I can not offhand
> > > tell if it matters, but you probably would care, at least for
> > > the primary recipients listed in @to array.
> > 
> > Well, it was kind of annoying to see the same email address appear 2-3
> > times in the email, because of the way I pull in all the relevant emails
> > from various places.  So I really needed a way to cull the duplicates.
> > I don't believe ordering is really significant in To: or Cc: lines, for
> > really anyone.  I could do soemthing like this, instead, I suppose:
> > 
> >     my @clean_to = ();
> >     my %dupe_check_to = ();
> >     foreach my $to_entry (@to) {
> >             if (!$dupe_check_to{Email::Valid->address($to_entry)}++) {
> >                     push @clean_to, $to_entry;
> >             }
> >     }
> > 
> >     my $to = join(", ", @clean_to);
> > 
> > I just like the first one a little better (though, I can't really pin
> > down why).
> 
> Or, more simply (if perl'y):
> 
>   my %tmp;
>   @to = grep { ! $tmp{Email::Valid->address($_)}++ } @to;
> 
> ...although I'd probably defensively localize the temporary var:
> 
>   {
>     my %tmp;
>     @to = grep { ! $tmp{Email::Valid->address($_)}++ } @to;
>   }

Duh. ENOCAFFEINE.

my %tmp;
@to = grep { ! $tmp->{$_}++ && Email::Valid->address($_) } @to;

> 
> -- 
> Short-term expediency always fails in the long term.
>                                           -- The Preacher at Arrakeen
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> Noel Maddy <[EMAIL PROTECTED]>
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
The more people you rule over, the less an individual matters.
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Noel Maddy <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to