my ($c,$mailcc,$mailto) =(0,'',''); foreach ( @{ $mailref } ){ #put first element in array as mail_to +and all others as CC if ($c == 0){ $mailto .= $_; }else{ $mailcc .= $_; } }
You don't change $c inside the loop so $mailto gets everything and $mailcc gets nothing. What you want is:
# put first element in array as mail_to and all others as CC my $mailto = shift @$mailref; my $mailcc = join '', @$mailref;
In reply to Re^5: RFC: beginner level script improvement
by jwkrahn
in thread RFC: beginner level script improvement
by georgecarlin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |