I am looking for a way to retrieve the "set explain on" results (usually in sqexplain.out) without writing to the file. My sql statements are executed via a cgi script and therefore, the user does not necessarily have an account to write to.

Also, I have not been able to execute a prepared compound sql statment that includes the "set explain on" statement followed by a select statement. Any insights?
Ex: $sth = $dbh->prepare("set explain on;
select * from tablename where field < condition;
set explain off");