I have a very simple example to illustrate the problem. Consider the following code block in Perl, in an org-mode file:
#+begin_src perl :results table
return qw(1 2 3);
#+end_src
It produces the following result:
#+results:
| 1\n2\n3\n |
which is not totally satisfactory since I was expecting a full org-table.
For instance, in Python the following code:
#+begin_src python :results table
return (1, 2, 3)
#+end_src
produces this result:
#+results:
| 1 | 2 | 3 |
So that’s apparently working in Python but not in Perl. Am I doing something wrong? Is this a known bug?
Since I felt a little masochistic this morning I decided to take a shot at hacking a little lisp again. I cooked up a small fix which works for your example but I can’t promise it will work more complex ones. So here it comes:
org-babel defines a wrapper for each language. The perl one did not produce something babel detects as a list so I modified it. In order to not make everything formated as a table I had to check if the result was printable as a table:
You can modify this further to fit your needs if you want to.
The next thing is that the
perl-evaluatemethod in babel does not run the output through further formating so I modified the evaluate method taking the new parts from thepython-evaluatecode:The new parts are
org-babel-perl-table-or-stringand the part inorg-babel-perl-evaluatebetween the empty lines (plus 1 closing parenthesis at the end).So what this now does is let perl print lists similar to the way python prints them and put the printed results through org-babel’s formating procedures.
Now to the result:
A List:
A scalar:
Ways you can use this code:
M-x eval-bufferfor testingI didn’t not tested this much further than the output examples I gave you so if it misbehaves for other examples feel free to complain.