You can open a file in Perl in several ways.
What you need to know is described in perl -f open
Here is an example:
my $file = 'filename.txt';
open my $ifh, '<', $file
or die "Cannot open '$file' for reading: $!";
local $/ = '';
my $contents = <$ifh>;
close( $ifh );
Now just email $contents
in your email.
I'm not sure how you are sending email, but the way I use frequently is as follows:
# Install these modules from CPAN:
use Mail::Sendmail;
use MIME::Base64;
sendmail(
To => '[email protected]',
From => 'Friendly Name <[email protected]>',
'reply-to' => '[email protected]',
Subject => 'That file you wanted',
# If you are sending an HTML file, use 'text/html' instead of 'text/plain':
'content-type' => 'text/plain',
'content-transfer-encoding' => 'base64',
Message => encode_base64( $contents ),
);