Sunday, June 14, 2009

Getting a Perl REPL in Emacs

Although Perl doesn't really have a REPL, you can use Perl's debug mode to obtain something as close to a REPL as you can get without installing extra software with the command perl -de1

So when in Emacs (or XEmacs or Aquamacs or whatever), using the following Emacs commands in sequence will open Perl's debug mode inside a horizontally split window:
C-x 2
C-x o
M-x shell
perl -de1
And away you go.

4 comments:

  1. there's supposedly a REPL module (Devel::REPL). Actually there may be lots of them.

    There's also SEPIA for Emacs: http://cpansearch.perl.org/src/SEANO/Sepia-0.97/Sepia.html

    ReplyDelete
  2. @Luke: After doing your steps in Emacs , how are you supposed to work with that setup ? I really don't get it. I guess the upper buffer is for editing and the lower buffer will evaluate the code. Right ? But how ?

    ReplyDelete
  3. @paines: What I suggested is a very primitive, ad-hoc REPL. It doesn't do much. I often want to test one-liners and this is perfect for that.

    If you want a more integrated solution with Emacs (similar to SLIME for Lisp developers), then I think SEPIA (as suggested by jdac above) might be better suited, although I haven't personally used it.

    ReplyDelete
  4. I see. Okay. Thank you Luke for clarification. BR

    ReplyDelete