Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:29:03+00:00 2026-06-18T10:29:03+00:00

I have a very simple example to illustrate the problem. Consider the following code

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:29:05+00:00Added an answer on June 18, 2026 at 10:29 am

    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:

    (setq org-babel-perl-wrapper-method
      "
    sub main {
    %s
    }
    @r = main;
    open(o, \">%s\");
    if ($#r > 0) {
    print o \"(\",join(\", \",@r), \")\",\"\\n\"
    } else {
    print o join(\"\\n\", @r), \"\\n\"
    }")
    

    You can modify this further to fit your needs if you want to.

    The next thing is that the perl-evaluate method in babel does not run the output through further formating so I modified the evaluate method taking the new parts from the python-evaluate code:

    (defun org-babel-perl-table-or-string (results)
      "Convert RESULTS into an appropriate elisp value.
    If the results look like a list or tuple, then convert them into an
    Emacs-lisp table, otherwise return the results as a string."
      (org-babel-script-escape results))
    
    
    (defun org-babel-perl-evaluate (session body &optional result-type)
      "Pass BODY to the Perl process in SESSION.
    If RESULT-TYPE equals 'output then return a list of the outputs
    of the statements in BODY, if RESULT-TYPE equals 'value then
    return the value of the last statement in BODY, as elisp."
      (when session (error "Sessions are not supported for Perl."))
    
        ((lambda (raw)
         (if (or (member "code" result-params)
             (member "pp" result-params)
             (and (member "output" result-params)
              (not (member "table" result-params))))
         raw
           (org-babel-perl-table-or-string (org-babel-trim raw))))
    
         (case result-type
           (output (org-babel-eval org-babel-perl-command body))
    
           (value (let ((tmp-file (org-babel-temp-file "perl-")))
            (org-babel-eval
             org-babel-perl-command
             (format org-babel-perl-wrapper-method body
                 (org-babel-process-file-name tmp-file 'noquote)))
            (org-babel-eval-read-file tmp-file))))))
    

    The new parts are org-babel-perl-table-or-string and the part in org-babel-perl-evaluate between 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:

    #+begin_src perl :results value
    return qw(1 2 3);
    #+end_src
    
    #+results:
    | 1 | 2 | 3 |
    

    A scalar:

    #+begin_src perl :results value
    return "Hello test 123";
    #+end_src
    
    #+results:
    : Hello test 123
    

    Ways you can use this code:

    1. Place it in scratch and M-x eval-buffer for testing
    2. Place it in a elsip src block at the beginning of your org-document
    3. Place it in your .emacs after babel is loaded
    4. Modify ob-perl.el in your lisp/org folder (might need to recompile org-mode afertwards)

    I 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a read statement that expects a number, very simple example code: program
I have very simple web page example read from html file using python. the
I have tried a very simple example of PHP MySQL Ajax following the example
I have a very simple log-in servlet with the following code: userName = request.getParameter(username);
I have a very simple example. A button on the bottom of the screen
I have this very simple example that I am using to learn structs in
I have very simple OpenGL ES example similar to Hehe's example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As
I have very simple piece of code. The goal is when i input four-digit
I have a very simple table called Member , which consists of the following:
I have a very simple fxml file, with a checkbox: ... <AnchorPane id=AnchorPane xmlns:fx=http://javafx.com/fxml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.