my $returned_data = $data_handle->fetchall_arrayref ({}); # Any other ops here, and then: print $q->header(-type => "application/json", -charset => "utf-8"); my $json = encode_json ($returned_data); print $json;