# put first element in array as mail_to and all others as CC my $mailto = shift @$mailref; my $mailcc = join '', @$mailref;