in reply to passing data using MIME::Lite

I can see some problems in your code.

First, you're using single quotes in the Data param, wich is going to insert you the literal text "&sql".

You're also printing what you want your function to return, not returning it. Maybe something like that (untested):

sub sql { my @output = $sqlCount->execute; my @data; while (@output=$sqlCount->fetchrow_array) { push @data, @output; } $sqlCount->finish(); $dbcon->disconnect(); return \@data }

And, in the Data field:

my $data = join "\n", @{ +sql() }; ... Data => $data ...