use MIME::Entity; my $msg = MIME::Entity->build( Type => 'multipart/mixed', From => 'me\@domain.com', To => $recipient, Cc => \@cc, Subject => 'the subject', Encoding => '8bit', ); $msg->attach(Data => $text_message, Type => 'text/plain', Encoding => '8bit', ); $msg->attach(Data => $html_message, Type => 'text/html', Encoding => '8bit', ); ### Send it: open MAIL, "| /usr/sbin/sendmail -t -oi -oem" or die "open: $!"; $msg->print(\*MAIL); close MAIL; #### my @data = ('one', 'two', 'three'); foreach (@data) { print "$_\n"; } for (my $i=0; $i < @data; $i++) { print "$data[$i]\n"; } __output__ one two three one two three