Re: [PATCH] send-email: allow use of basic email list in --cc --to and --bcc
- From
benoît person <benoit.person@gmail.com>
- Date
- Jun 18, 2013, 10:26 UTC
- Message-ID
- <CAETqRCjCf0HKfAsgcWPnv81OY07T0JZdXVGGr-DgLsP3miWUvQ@mail.gmail.com>
- In-Reply-To
- <1371549079-19291-1-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>
Show 19 quoted lines
> +sub split_email_list {
> + my(@list) = @_;
> + my @tmp;
> + my @emails;
> + for (my $i = 0; $i <= $#list; $i++) {
> + if ($list[$i] =~ /,/) {
> + @emails = split(/,/, $list[$i]);
> + } else {
> + @emails = $list[$i];
> + }
> + # Removal of unwanted spaces
> + for (my $j = 0; $j <= $#emails; $j++) {
> + $emails[$j] =~ s/^\s+//;
> + $emails[$j] =~ s/\s+$//;
> + }
> + @tmp = (@tmp, @emails);
> + }
> + return(@tmp);
> +}Why two regex ? You could do something like : $emails[$j] =~ s/^\s+|\s+$//g; to remove leading and trailing whitespaces at the same time.
I think it's better to use the builin 'push' function to concatenate your two arrays: push(@tmp, @emails);
Benoit Person