in reply to join email lists with comma unless one list is empty

Just for fun, something a little more robust/checky. It can be made deeper to avoid obvious bounces and non-existent end points. See the doc: Email::Valid.

use Email::Valid; use Carp qw( cluck ); sub join_email_lists { join ",", grep { Email::Valid->address($_) } @_; } sub join_email_lists_with_feedback { my @list; my @err; for my $address ( @_ ) { if ( Email::Valid->address($address) ) { push @list, $address; } else { push @err, $address; } } cluck "Problem address(es): ", join(", ", @err) if @err; join ",", @list; }