Input data of a file from perl into HTML table

Hi ,
I need an help in perl scripting.
I have an perl script written and i have an for loop in that ,where as it writes some data to a file and it has details like below.

 cat out.txt
This is the first line 
this is the second line.
.....

Now, this file needs to be send in mail in HTML format.

so far ,i have done

sub blah
{
        my $message = shift;
        open    blah, ">>", $data_file or die "Unable to write to $data_file";
        print   blah "$message\n";
        close   blah
}
foreach $e ()
{
blah("<tr><td bgcolor=#B2CAF6><b>Data:</b></td><td>`cat out.txt`</td></tr>");
}

with this code am not able get what i am expecting, it give the output in the mail as

Data: `cat out.txt` in the table.

Please help me out here.

You can open() out.txt and read it, assign it's input into a variable. After that you write the content into the new file with your html stuff surrounding. Basically the same like you already open the file for appending, just add it before that step.
It would be good not to use the same name for the file handle like the name of the sub routine.
If you use die() , you might want to add $! to print the original error message too.

thanks zaxxon for your reply.

But sorry am afraid ,i didnt get quite clear.

But i have tried something similar of what you are trying to say ? please correct me if this is not your perception.

$value=(open my $output, ">","out.txt" );
blah("<tr><td bgcolor=#B2CAF6><b>Data:</b></td><td>$value</td></tr>");

but not sure... what is the issue in that.. its giving the output in the mail as
Data: $value

to add more here, am generating the html mail from unix shell script from the file created from the sub routine.
and i have called the shell script inside the perl.

---------- Post updated at 12:25 PM ---------- Previous update was at 10:44 AM ----------

Could someone please help me here ?