ob-perl: fix result handling

* lisp/ob-perl.el (org-babel-perl-wrapper-method): Select output
  handle only after evaluation so that output is not mixed into
  results eavaluation.
  (org-babel-perl-evaluate): Fix the handling of results for ":results
  output" to also parse tables.  Use the same lambda construction as
  in ob-sh.el to avoid code duplication.
This commit is contained in:
Achim Gratz 2013-04-17 21:38:21 +02:00
parent 99f8821995
commit f6bf19f898
1 changed files with 20 additions and 14 deletions

View File

@ -101,9 +101,9 @@ specifying a var of the same value."
%s %s
}; };
open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/); open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/);
select $BOH;
my $rv = &$babel_sub(); my $rv = &$babel_sub();
my $rt = ref $rv; my $rt = ref $rv;
select $BOH;
if (qq(ARRAY) eq $rt) { if (qq(ARRAY) eq $rt) {
local $\\=$/; local $\\=$/;
local $,=qq(\t); local $,=qq(\t);
@ -131,19 +131,25 @@ If RESULT-TYPE equals 'output then return a list of the outputs
of the statements in BODY, if RESULT-TYPE equals 'value then of the statements in BODY, if RESULT-TYPE equals 'value then
return the value of the last statement in BODY, as elisp." return the value of the last statement in BODY, as elisp."
(when session (error "Sessions are not supported for Perl")) (when session (error "Sessions are not supported for Perl"))
(let ((body (concat org-babel-perl-preface ibody))) (let* ((body (concat org-babel-perl-preface ibody))
(case result-type (tmp-file (org-babel-temp-file "perl-"))
(output (org-babel-eval org-babel-perl-command body)) (tmp-babel-file (org-babel-process-file-name
(value (let ((tmp-file (org-babel-temp-file "perl-"))) tmp-file 'noquote)))
(org-babel-eval ((lambda (results)
org-babel-perl-command (when results
(format org-babel-perl-wrapper-method body (org-babel-result-cond result-params
(org-babel-process-file-name tmp-file 'noquote))) (org-babel-eval-read-file tmp-file)
(org-babel-result-cond result-params (org-babel-import-elisp-from-file tmp-file '(16)))))
(with-temp-buffer (case result-type
(insert-file-contents tmp-file) (output
(buffer-string)) (with-temp-file tmp-file
(org-babel-import-elisp-from-file tmp-file '(16)))))))) (insert
(org-babel-eval org-babel-perl-command body))
(buffer-string)))
(value
(org-babel-eval org-babel-perl-command
(format org-babel-perl-wrapper-method
body tmp-babel-file)))))))
(provide 'ob-perl) (provide 'ob-perl)