From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: evaluation of perl in babel Date: Sun, 24 Feb 2013 23:09:04 +0100 Message-ID: <87wqtxfjpb.fsf@Rainer.invalid> References: <87hal1whbc.fsf@mn.cs.uvic.ca> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9jl4-00032C-Cx for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 17:09:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9jl2-0007rg-Vb for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 17:09:22 -0500 Received: from plane.gmane.org ([80.91.229.3]:36753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9jl2-0007rT-Os for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 17:09:20 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1U9jlK-0007aj-Dp for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 23:09:38 +0100 Received: from pd9eb3d78.dip.t-dialin.net ([217.235.61.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Feb 2013 23:09:38 +0100 Received: from Stromeko by pd9eb3d78.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Feb 2013 23:09:38 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org D M German writes: > There are some bugs. For example, the interpretation of :results table, > vector and list. You may misunderstand some things, or I don't understand what you are asking. It is (at least currently) the responsibility of the Perl program (or any other Babel language) to deliver the result in such a way that it can be interpreted correctly by the result type chosen (in other word, the program output must be valid Org syntax in the given context). You can't have the same program produce tables, vectors and LaTeX output just by switching the results type. > But I think the main problem comes from the way that Babel expects the > result. In Babel, and except for :results output, the last expression in > perl is considered the input to the results. That is with the default wrapper function, which expects the program to return something that either is a string or interpolates to a string that Babel can interpret. You can easily define one yourself that does different things, like simply open the output file then select the filehandle for output. That's what I'd do in any case and I think it would work just as you want. --8<---------------cut here---------------start------------->8--- (defvar org-babel-perl-wrapper-method "{ my $prog = q(%s); open my $BO, qq(>%s) or die qq(Perl: Could not open output file.$\\); select $BO; eval( $prog ); }") --8<---------------cut here---------------end--------------->8--- > This is implementing by > saving the last expression into a variable, and printing each value > separated by a "\n" (including the last). So basically, org takes the > last expression, and outputs them to the babel input file one per line. Yes, not the most elegant way, not perlish and all that; but there's nothing to stop you from making that last expression a string variable that has collected your output. Try the above and let me know if that addresses your concerns, if only partly. As for debugging, the output files that Perl produces and Babel then interprets are kept in the temporary folder, org-babel-eval-read-file doesn't delete them after use (it probably should, though). Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Waldorf MIDI Implementation & additional documentation: http://Synth.Stromeko.net/Downloads.html#WaldorfDocs