From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: evaluation of perl in babel
Date: Sun, 24 Feb 2013 23:09:04 +0100 [thread overview]
Message-ID: <87wqtxfjpb.fsf@Rainer.invalid> (raw)
In-Reply-To: 87hal1whbc.fsf@mn.cs.uvic.ca
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
next prev parent reply other threads:[~2013-02-24 22:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-24 21:08 evaluation of perl in babel D M German
2013-02-24 21:25 ` dmg
2013-02-24 22:09 ` Achim Gratz [this message]
2013-02-25 9:54 ` D M German
2013-02-25 9:57 ` dmg
2013-02-25 14:11 ` Eric Schulte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wqtxfjpb.fsf@Rainer.invalid \
--to=stromeko@nexgo.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).