in reply to Output data into an email message.

open(RES,"type bas.txt |"); while(<RES>) { print $_; }

could be written as:

open(RES,"bas.txt"); @text = <RES>; $all_text = join(@text); print $all_text; ... Message = $all_text;

update: I took too long to type... See the message before this :)