my $file = 'mailmessage'; open( my $fh, $file ) or die "couldn't read file - $!"; my $mailContents; { local $/; $mailContents = <$fh>; } close( $fh );