in reply to extract data from a form .. and attach a file in sendmail
Look at MIME::Lite. Attachments are just a mime type. I used MIME::Lite to send emails with HTML attachments. With MIME::Lite you can send any type of file as it is just encoded and sent at the end of the email.